Javascript running in Safari has a problem with my birthday. This sometimes breaks validation in forms for me (as forms check the input with the javascript output, and the days don't match anymore). I'd love to know why this happens.
My birthday is 6th Oct 1985. In Javascript, I create this using:
new Date(1985, 09, 06)
(Note that months are zero-indexed, but days and years are not.)
// My birthday
console.log("1985, 09, 06: " + new Date(1985, 09, 06))
// One day earlier/later
console.log("1985, 09, 07: " + new Date(1985, 09, 07))
console.log("1985, 09, 05: " + new Date(1985, 09, 05))
// One month earlier/later
console.log("1985, 10, 06: " + new Date(1985, 10, 06))
console.log("1985, 08, 06: " + new Date(1985, 08, 06))
// One year earlier/later
console.log("1986, 09, 06: " + new Date(1986, 09, 06))
console.log("1984, 09, 06: " + new Date(1984, 09, 06))
Results running this in Safari are:
// My birthday (note the day is wrong, and the time is 11pm)
Sat Oct 05 1985 23:00:00 GMT+1000 (AEST)
// One day earlier/later
Mon Oct 07 1985 00:00:00 GMT+1100 (AEDT)
Sat Oct 05 1985 00:00:00 GMT+1000 (AEST)
// One month earlier/later
Wed Nov 06 1985 00:00:00 GMT+1100 (AEDT)
Fri Sep 06 1985 00:00:00 GMT+1000 (AEST)
// One year earlier/later
Mon Oct 06 1986 00:00:00 GMT+1100 (AEDT)
Sat Oct 06 1984 00:00:00 GMT+1000 (AEST)
https://jsfiddle.net/27bupLr9/
In Chrome, my birthday is created correctly:
console.log(new Date(1985, 09, 06))
Sun Oct 06 1985 00:00:00 GMT+1000 (AEST)
This has been resolved in macOS High Sierra.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments