Javascript Date.getTimezoneOffset ()

I am trying to compare GMT time offset from operating system to GMT time offset from Javascript Date.getTimezoneOffset (). The problem is that windows give an offset based on EST, while javascript gives an offset based on EDT. There is a difference in hours between the two watches. Does anyone know how to get Javascript to use standard times like windows? Thanks.

+5
source share
2 answers

Why not call getTimezoneOffset on a date when you know that daylight saving time is not valid?

javascript:alert(new Date('1/1/2009').getTimezoneOffset()) 

This will give 300 (5 hours).

+4
source

Please note that the first published answer only works in half of all cases, so on average it doesn't work at all.

The first of January, as you know, is not in the summer only in the northern hemisphere. However, this is only half the world.

 var jan = new Date( 2009, 0, 1, 2, 0, 0 ), jul = new Date( 2009, 6, 1, 2, 0, 0 ); var offset = ( jan.getTime() % 24 * 60 * 60 * 1000 ) > ( jul.getTime() % 24 * 60 * 60 * 1000 ) ?jan.getTimezoneOffset() : jul.getTimezoneOffset(); 
+12
source

All Articles