function showTime() { var d, small_time, big_time; d = new Date; small_time = d.getHours() + ':' + zeroPad(d.getMinutes(), 2); alert(small_time); // eg 14:04 big_time = d.toLocaleTimeString(); alert(big_time); // eg 2:04:05 PM }The helper function zeroPad() can be found here: http://davekb.com/search.php?target=javascript+zeroPad
Programming Tips - How do I display the current local time?
Date: 2010may4
Language: javaScript
Platform: web
Level: beginner
Q. How do I display the current local time?
A. Here are two ways: