Tuesday, 15 June 2010

Convert UTC time to hours, minutes, and AM/PM format in javascript -



Convert UTC time to hours, minutes, and AM/PM format in javascript -

given utc time, simple way of converting format in hours, minutes, , am/pm (e.g. '3:30 pm')?

<script type="text/javascript"> <!-- var a_p = ""; var d = new date(); var curr_hour = d.gethours(); if (curr_hour < 12) { a_p = "am"; } else { a_p = "pm"; } if (curr_hour == 0) { curr_hour = 12; } if (curr_hour > 12) { curr_hour = curr_hour - 12; } var curr_min = d.getminutes(); document.write(curr_hour + " : " + curr_min + " " + a_p); //--> </script>

http://www.webdevelopersnotes.com/tips/html/formatting_time_using_javascript.php

javascript time utc

No comments:

Post a Comment