Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function telltime() {
- var hour = new Date().getHours(),
- min = new Date().getMinutes(),
- sec = new Date().getSeconds(),
- month = new Date().getMonth() + 1,
- day = new Date().getDate(),
- year = new Date().getFullYear(),
- ampm;
- switch (new Date().getDay()) {
- case 0:
- today = "Sunday";
- break;
- case 1:
- today = "Monday";
- break;
- case 2:
- today = "Tuesday";
- break;
- case 3:
- today = "Wednesday";
- break;
- case 4:
- today = "Thursday";
- break;
- case 5:
- today = "Friday";
- break;
- case 6:
- today = "Saturday";
- }
- if (sec < 10) sec = `0${sec}`
- if (min < 10) min = `0${min}`
- if (hour > 12) {
- ampm = 'PM';
- } else {
- ampm = 'AM';
- }
- if (hour > 12) hour -= 12
- alert(`The current time is:\n\n${month}/${day}/${year}\n${today} ${day}, ${year}\n${hour}:${min}:${sec} ${ampm} ${new Date().toString().slice(35,new Date().toString().length - 1)}`);
- }
- telltime();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement