Last active
June 18, 2018 16:23
-
-
Save tithi021/0321ec5498ad45a54049e18ee2421e1e to your computer and use it in GitHub Desktop.
Display the current day and time - Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var today = new Date(); | |
var day = today.getDay(); | |
var dayList = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Thursday']; | |
var hour = today.getHours(); | |
var minutes = today.getMinutes(); | |
var seconds = today.getSeconds(); | |
var prepand = ''; | |
if(hour >= 12) { | |
hour = hour - 12; | |
prepand = 'PM'; | |
} else { | |
prepand = 'AM'; | |
} | |
console.log('Current time is: ' + hour + ':' + minutes + ':' + seconds + ' ' + prepand); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment