-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
42 lines (34 loc) · 1.33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Today's date with day/month prefixed zero</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="prism/prism.css" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
</head>
<body>
<h1>Today's date with leading zeros</h1>
<p>If day/month is less than '10', it is prefixed with zero. No more, no less.</p>
<p>Today: <span id="date"></span> (last updated: <span id="update"></span>)</p>
<p>For <a href="https://github.com/DaveEveritt/leading-zero-dates/blob/master/readme.md">TODOs see README</a></p>
<pre><code class="language-javascript">{
'use strict';
const d = new Date();
zeroPrefix = function (needZero) {
return (needZero < 10) ? `0${needZero}` : needZero;
};
const now = {
day: zeroPrefix(d.getDate()),
month: zeroPrefix(d.getMonth()+1),
year: d.getFullYear()
}
document.getElementById("date").innerHTML=`${now.day}/${now.month}/${now.year}`;
}
</pre></code>
<p><a href="https://github.com/DaveEveritt/leading-zero-dates">Source code on GitHub</a>, code highlighting with <a href="http://prismjs.com/">Prism by Lea Verou</a></p>
<script src="js/date-with-zero.js"></script>
<script src="js/update-with-zero.js"></script>
<script src="prism/prism.js"></script>
</body>
</html>