commit
d70e2df5ed
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#### Features:
|
#### Features:
|
||||||
|
|
||||||
- **Clock and Date** functions
|
- **Clock and Date** format can be set to 24 hour (default) or 12 hour
|
||||||
- **Greetings**: easy to change and modify
|
- **Greetings** are easy to change and modify
|
||||||
- **Variables** for custom colors in the `css` code
|
- **Variables** for custom colors in the `css` code
|
||||||
- **Modular** javascript files for an easy read
|
- **Modular** javascript files for an easy read
|
||||||
|
|
||||||
|
17
js/time.js
17
js/time.js
@ -15,18 +15,25 @@ function displayClock() {
|
|||||||
'Dec',
|
'Dec',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Set to true to use a 12 hour date format
|
||||||
|
var format_12hour = false;
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var mm = monthNames[d.getMonth()];
|
var mm = monthNames[d.getMonth()];
|
||||||
var dd = d.getDate();
|
var dd = d.getDate();
|
||||||
var min = (mins = ('0' + d.getMinutes()).slice(-2));
|
var min = (mins = ('0' + d.getMinutes()).slice(-2));
|
||||||
var hh = d.getHours();
|
var hh = d.getHours();
|
||||||
|
var ampm = '';
|
||||||
|
|
||||||
|
if (format_12hour) {
|
||||||
|
ampm = hh >= 12 ? ' pm' : ' am';
|
||||||
|
hh = hh % 12;
|
||||||
|
hh = hh ? hh : 12; //show mod 0 as 12
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('hour').innerText = hh;
|
document.getElementById('hour').innerText = hh;
|
||||||
document.getElementById('separator').innerHTML = ' : ';
|
document.getElementById('separator').innerHTML = ' : ';
|
||||||
document.getElementById('minutes').innerText = min;
|
document.getElementById('minutes').innerText = min + ampm;
|
||||||
|
|
||||||
document.getElementById('month').innerText = mm;
|
|
||||||
document.getElementById('day').innerText = dd;
|
|
||||||
|
|
||||||
setTimeout(displayClock, 1000);
|
setTimeout(displayClock, 1000);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user