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 exactly 3600 secs before the Java timestamp. I could reproduce it for Oct 1st, but for Jan 1st it's ok.
My test case (in groovy, using the usual Java API on purpose):
def sdf = new SimpleDateFormat("dd/MM/yyyy")
["01/10/1956", "01/01/1956", "01/10/1978"].each {
def d = sdf.parse(it)
println "${it} -> ${d.time}"
}
and in JS (I simply run it from the Chrome console - "9" is October here):
new Date(1956, 9, 1, 0, 0, 0).getTime()
A few samples:
*Groovy
- 01/10/1956 -> -418179600000
- 01/01/1956 -> -441853200000
- 01/10/1978 -> 276040800000
*Javascript
- 1956,9,1,0,0,0 -> -418183200000
- 1956,0,1,0,0,0 -> -441853200000
- 1978,9,1,0,0,0 -> 276040800000
=> Notice how 01/10/1956 is not converted the same way, yielding a 3600 seconds difference.
A daylight saving time or a timezone would be the perfect culprit but I don't see why the two universe diverged at some point in the past.
Any hint welcome!
Thank you
EDIT more samples
*Java/Groovy
01/01/1974 -> 126226800000
01/10/1974 -> 149814000000
01/01/1976 -> 189298800000
01/10/1976 -> 212972400000
01/01/1978 -> 252457200000
01/10/1978 -> 276040800000
*JS
new Date(1974, 0, 1, 0, 0, 0).getTime() 126226800000
new Date(1974, 9, 1, 0, 0, 0).getTime() 149814000000
new Date(1976, 0, 1, 0, 0, 0).getTime() 189298800000
new Date(1976, 9, 1, 0, 0, 0).getTime() 212972400000
new Date(1978, 0, 1, 0, 0, 0).getTime() 252457200000
new Date(1978, 9, 1, 0, 0, 0).getTime() 276040800000
Around 1967~1971
01/01/1967 -> -94698000000
01/04/1967 -> -86922000000
01/10/1967 -> -71110800000
01/01/1968 -> -63162000000
01/04/1968 -> -55299600000
01/10/1968 -> -39488400000
01/01/1971 -> 31532400000
01/10/1971 -> 55119600000
new Date(1967, 0, 1, 0, 0, 0).getTime() -94698000000
new Date(1967, 3, 1, 0, 0, 0).getTime() -86925600000
new Date(1967, 9, 1, 0, 0, 0).getTime() -71114400000
new Date(1968, 0, 1, 0, 0, 0).getTime() -63162000000
new Date(1968, 3, 1, 0, 0, 0).getTime() -55303200000
new Date(1968, 9, 1, 0, 0, 0).getTime() -39492000000
new Date(1971, 0, 1, 0, 0, 0).getTime() 31532400000
new Date(1971, 9, 1, 0, 0, 0).getTime() 55119600000