Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8634329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:41:53+00:00 2026-06-12T09:41:53+00:00

I noticed something weird with timezones and Javascript Date object. Trying this on a

  • 0

I noticed something weird with timezones and Javascript Date object.

Trying this on a Linux box:

$ TZ='America/Sao_Paulo' js 
js> new Date(2012, 9, 21, 0, 0, 0).toString() 
"Sat Oct 20 2012 23:00:00 GMT-0300 (BRST)"

I found it impossible to get an object that represents the 21th of october 2012. Every attemps to get a Date between 00:00 and 01:00 that day results in a date the day before between 11:00 PM and 00:00.

(Windows user may change their timezone to Brasilia/GMT-03 to experience the same behavior)

Adding one hour (or one day) to such a date object results in getting back the same date.

I guess it has to do with daylight saving time which occurs on that specific date in Brazil, however I absolutely don’t know how to deal with that.

I have a loop that iterates over the days of the month (for a calendar application) and it obviously loops forever in that case when reaching the 20th of october 2012.

There must be something I’m doing wrong, but I don’t know how to deal with such a case, as I guess it could also happen for other timezones.

What is the recommended way of dealing with Date in Javascript to ensure that such timezone/daylight saving time related problems do not occur ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:41:54+00:00Added an answer on June 12, 2026 at 9:41 am

    This is an absolutely correct behavior. Due to the DST midnight simply does not exist in local time in Brazil on October 21st. If you just need to build a calendar you can just use new Date(2012, 9, 21, 0, 0, 0).toUTCString() instead of new Date(2012, 9, 21, 0, 0, 0).toString() and other UTC methods.

    For example to create an UTC date you can use new Date(Date.UTC(2012, 9, 21, 0, 0, 0));.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I was creating new instances and I noticed something weird on it. I
While playing with VS11 beta I noticed something weird: this code couts f took
I noticed something when I was attempting this today: <g:remoteField action=getReportsToResults update=reportsToResultsDiv paramName=search name=reportsToResults
I just noticed something strange. If I have this XML: <level number=7 background=background_5> and
I was coding today and noticed something. If I open a new interpreter session
I was looking at Static variables in JavaScript and I noticed something I'd seen
OK, I realize that question might seem weird, but I just noticed something that
Ok this is something weird. I got authlogic-oid installed in my rails app today.
In the last past days I noticed something weird optimizing my query. I have
I am working on a WCF SOAP service, and I noticed something weird. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.