Click to See Complete Forum and Search --> : Time javascript and DST


Rattlebones
04-14-2004, 08:35 AM
Just wondering if anyone knew of a good javascript which accounts for Daylight Saving Time?

Haven't been able to track one donw.

Thanks.
Rattlebones

requestcode
04-14-2004, 09:54 AM
What do you want the script to do? Also, have you check out this place:
http://www.javascriptkit.com/script/cutindex1.shtml

Rattlebones
04-14-2004, 09:59 AM
My ultimate goal is to post GMT, Easter, Central, Mountain and Pacific live clocks.

However, GMT/UTC doesn't use Daylight Saving Time so I need a script that can calculate whether we are in DST or not correctly so each of the 5 clocks will be correct.

The world time zone one on the URL above is nice but I want it to all be automatic. There you need to interact, I just want the clocks there automatically.

If you look at http://www.potterwatch.com/CCG/times.html you'll see what I'm trying to do. I've got the clocks displayed right but I need to change the code when DST ends.

Thanks : Rattlebones

Juuitchan
04-14-2004, 01:39 PM
Just so you know:

Americans write the date month/day/year, where year is usually 2 digits. The month and day can be zero-padded but usually aren't. So April 14, 2004 would be 4/14/04.

I think that browsers might allow for American DST automatically. I don't know if this is true internationally, though. I also don't know if it depends on the user's regional settings.

If you want to know whether DST is in effect on a given date, try doing arithmetic on the date or something.

In Netscape, your form doesn't look right: most of the text is not visible.

Rattlebones
04-14-2004, 04:46 PM
Err. Oops. Thanks. I had checked it in IE and Opera but not Mozilla (firefox) and Netscape. I fixed that little problem.

I am aware of the date differences. And I'm not too concerned about USers need to translate a date a little bit.

I've done some messing about and I can do the raw coding but haven't found something to automagically account for DST. I use

var TZL = nowL.getTimezoneOffset();

to get the timezone on this PC and use that to figure out UTC then use UTC/GMT to figure out ET/CT/MT/PT.

I'd like to automate the DST considerations which right now I'll have to do manually w/ the coding I have. I think :)

Rattlebones
04-14-2004, 04:53 PM
You know what, I believe that my code will account for DST. I changed my PC to be Arizona time which doesn't use DST and the GMT was correct... or as correct as it gets on this PC :)...

Thanks for the help and the heads up on the Netscape FUBAR.