Created
January 31, 2012 03:17
-
-
Save tebriel/1708512 to your computer and use it in GitHub Desktop.
format 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
function formatTime(e) | |
{ | |
var hour_value = e.getHours(); | |
var minutes_value = '00'; | |
minute_value = e.getMinutes(); | |
if (minute_value == 0) | |
{ | |
minute_value = '00'; | |
} | |
else if (minute_value < 10) | |
{ | |
minute_value = '0' + minute_value; | |
} | |
var AMorPM = "AM"; | |
if (hour_value > 12) | |
{ | |
hour_value -= 12; | |
AMorPM = "PM"; | |
} | |
if (hour_value == 0) | |
{ | |
hour_value = 12; | |
} | |
var formatedTime = hour_value + ":" + minute_value + " " + AMorPM; | |
return formatedTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment