Skip to content Skip to sidebar Skip to footer

Timestamp Deviation Java Vs Javascript For Old Dates (3600secs)

When converting string date representation to numeric values, I obtain a different result in Java/Groovy/PHP vs in Javascript. For some dates before 1970, the JS timestamp is exact

Solution 1:

Your profile says you're from Belgium.

There's no daylight saving time in 1976 for Brussels:

http://www.timeanddate.com/worldclock/clockchange.html?n=48&year=1976

But there is from 1977 onwards:

http://www.timeanddate.com/worldclock/clockchange.html?n=48&year=1977

Java is probably aware of this, whereas JavaScript is not.

Solution 2:

The information about Timezones is complex and you would be surprised how often a) they change, b) they are inaccurate.

I would try this in Java/Groovy as well.

new Date(1956, 9, 1, 0, 0, 0).getTime()

A cool website on timezones. http://www.bbc.co.uk/news/world-12849630

For example, the epoch is 1970/01/01 00:00 UTC. Not Europe/London because even though it was winter, the UK was in BST (British Summer Time) This only happen from Feb 1968 to Nov 1971. :P http://www.timeanddate.com/time/uk/time-zone-background.html

The more you learn about time and date the more you realise its all rather adhoc. Even UTC is not an acronym as such, it means "Coordinated Universal Time" in English and "Temps Universel Coordonné" in French, and because they couldn't agree on what the acronym should be the compromise was UTC with is neither. http://en.wikipedia.org/wiki/Coordinated_Universal_Time

Post a Comment for "Timestamp Deviation Java Vs Javascript For Old Dates (3600secs)"