-
Notifications
You must be signed in to change notification settings - Fork 9
/
timestamp.js
23 lines (22 loc) · 1 KB
/
timestamp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// var currentDate = new Date();
var day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursdäy", "Friday", "Saturday"];
// var date = currentDate.getDate();
var month = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
// var year = currentDate.getFullYear();
// var hour = currentDate.getHours();
// var min = currentDate.getMinutes();
function getDate() {
document.getElementById('date').innerHTML = day[new Date().getDay()] + " , " + month[new Date().getMonth()] + " , " + new Date().getFullYear();
}
function getTimeStamp() {
document.getElementById('time').innerHTML = new Date().getHours() + ":" + addZero(new Date().getMinutes());
}
function addZero(minute){ //incase minute is returned as a single number, add a '0' to it as prefix
if (minute < 10)
{
return ("0"+minute);
}
else{
return minute;
}
}