Results 1 to 1 of 1
Thread: detecting gmt timezone offset
Mar 21, 2004, 10:26 #1
detecting gmt timezone offset
I've tried date.getTimezoneOffset()/60 (where date is a a Date() object), and it works nicely, except for one small issue - it alwasy returns a positive offset, no matter if the user is in -5 or +5 GMT for instance.
Next thing I tried is converting a date object to a string. It ended up having "... -5000 (Eastern Standard...". Good I think, as I can parse it. But then this went downhill as IE doesn't send that -5000 and just sends an "...EST..." Needless to say, not my idea of fun parsing when each browser has it's own version.
Is there something else I'm missing with which I can get the offset?
EDIT: found myself a solution using both server side scripting, and java_script_:
Math.round((d.getHours()*3600+d.getMinutes()*60+d.getSeconds())/3600)-<?php echo gmdate('H',time()); ?>
Last edited by Codename49; Mar 21, 2004 at 11:13.