I wrote some code in Javascript that was working without any problem.
But when I put the date October 20, 2013
, I was returned the date October 19, 2013
.
The same applies to the years 2019
, 2024
and 2030
(not tested
previous years and not later).
This problem shows up in all browsers I test (Google Chrome, Internet Explorer, Mozilla Firefox, Opera and Safari).
When I write:
date = new Date("10/20/2013");
document.write(date);
The result I get is:
Sat Oct 19 2013 23:00:00 GMT-0300 (BRT)
Someone could tell me why this is happening and how can I solve this problem?
October 20th, 2013 is the cutover for BRST. So if you are in Brazil (in a BRST timezone) you will transition from BRT (UTC -3) to BRST (UTC-2).
From TimeAndDate.com:
Current time in São Paulo: Wednesday, May 22, 2013 at 3:19:14 PM BRT
São Paulo will stay on BRT until Sunday, October 20, 2013 going to BRST
The transition happens at Midnight and Midnight to 1am is skipped. To guarantee a time on that date you can try:
date = new Date("10/20/2013 01:00:00");
And you should get 10/20/2013 01:00:00
with BRST as the timezone designation.
For someone in a US timezone that participates in DST who wants to see this issue; Use the US daylight savings time transition point of March 10th 2013, where 2am is skipped ahead to 3am:
var d = new Date("03/10/2013 02:59:59")
alert(d); // Returns 1:59:59 AM in the Standard Time Zone
var d = new Date("03/10/2013 03:00:00")
alert(d); // Returns 3:00:00 AM in the Daylight Time Zone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With