SuPrAiCeR69
May 6th 2009, 7:33 pm
I looked around for a 24hr JS time script and found the following from http://www.crays.com/jsc/jsC4Udate.htm:
Time in 24-hr format
<SCRIPT Language="JavaScript">
<!-- hide from old browsers
var curDateTime = new Date()
var curHour = curDateTime.getHours()
var curMin = curDateTime.getMinutes()
var curSec = curDateTime.getSeconds()
var curTime =
((curHour < 10) ? "0" : "") + curHour + ":"
+ ((curMin < 10) ? "0" : "") + curMin + ":"
+ ((curSec < 10) ? "0" : "") + curSec
document.write(curTime)
//-->
</SCRIPT>
After testing it, I realised at 12pm the time goes to "00:00:00" instead of staying at 12. At 12am the time goes to "00:00:00" which is fine. How can I fix this or is there a better written script around?
Time in 24-hr format
<SCRIPT Language="JavaScript">
<!-- hide from old browsers
var curDateTime = new Date()
var curHour = curDateTime.getHours()
var curMin = curDateTime.getMinutes()
var curSec = curDateTime.getSeconds()
var curTime =
((curHour < 10) ? "0" : "") + curHour + ":"
+ ((curMin < 10) ? "0" : "") + curMin + ":"
+ ((curSec < 10) ? "0" : "") + curSec
document.write(curTime)
//-->
</SCRIPT>
After testing it, I realised at 12pm the time goes to "00:00:00" instead of staying at 12. At 12am the time goes to "00:00:00" which is fine. How can I fix this or is there a better written script around?