
Originally Posted by
jscheuer1
if (curHour = 24) curHour = 0
That would always set curHour to zero as assignment of 'true' values (those other than an empty string, boolean false, zero [0], null, and undefined) will always evaluate to true.
I know; it was a typo. 
The original code could have also been changed so that
Code:
if (curHour > 24) curHour -= 24
became:
Code:
if (curHour >= 24) curHour -= 24;
Anyway, the simpler approach is:
Code:
var now = new Date(),
h = now.getUTCHours(),
m = now.getUTCMinutes(),
s = now.getUTCSeconds();
document.write((h < 10 ? '0' : '') + h + ':'
+ (m < 10 ? '0' : '') + m + ':'
+ (s < 10 ? '0' : '') + s + ' GMT');
The UTC methods return the time without timezone/DST compensation so no adjustments are necessary at all.
Mike
Bookmarks