Created
October 10, 2012 19:06
-
-
Save jasonhwest/3867727 to your computer and use it in GitHub Desktop.
User Local Time
This file contains 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 currentTime = new Date(); | |
var hours = currentTime.getHours(); | |
var minutes = currentTime.getMinutes(); | |
var suffix = "AM"; | |
if (hours >= 12) { | |
suffix = "PM"; | |
hours = hours - 12; | |
} | |
if (hours == 0) { | |
hours = 12; | |
} | |
if (minutes < 10) minutes = "0" + minutes; | |
document.write("<b>" + hours + ":" + minutes + " " + suffix + "</b>") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment