
Originally Posted by
jscheuer1
if ('number'==typeof today.getUTCHours()){
If you're attempting to check that the getUTCHours method is supported, that isn't the way to go about it. You need to check that the method itself is available, not that it's return value is correct. If a host doesn't support a function, the script will error out - precisely what you should be trying to avoid.
In this instance,
Code:
if(today.getUTCHours) {
would be sufficient. However, I really don't believe it's necessary. The UTC methods have been supported since fourth generation browsers, and they're obsolete as it is.
By the way, constructing strings and using the parse method is a really obtuse way of doing this. Subtracting Date objects directly will result in the same millisecond value and is far more efficient.
Code:
function countdown() {
var est = new Date(),
target = new Date(yr, mo, da, hr, min, sec);
est.setUTCHours(est.getUTCHours - 5);
dd = target - est;
/* ... */
}
Untested, but I don't see how it would behave any differently.
Mike
Bookmarks