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 7954317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:23:36+00:00 2026-06-04T03:23:36+00:00

When creating a new Date object using numbers for the parts, the value I

  • 0

When creating a new Date object using numbers for the parts, the value I get back is exactly one month ahead of the value I put in for ‘month’.

new Date(2012, 05, 17, 00, 00, 00)
Sun Jun 17 2012 00:00:00 GMT+0800 (HKT)  // june?!

However, a normal parse of exactly the same string returns the correct time:

new Date("2012-05-17 00:00:00")
Thu May 17 2012 00:00:00 GMT+0800 (HKT)

I get the same result in ie/ff/chrome. Removing hours/min/seconds doesn’t have any effect. I can work around it by subtracting one before setting the month, but instead I just switched to writing out my date as a string.

Edit:
The string parse doesn’t work in IE. I have no idea what I did, but I swear I made that work. Thats prob. why I avoided it in the first place. I’ve switched to using moment.js for now.

Ah, now I get it. Just like regular java dates, which I don’t code in except rarely, and even then always with a library (joda, etc). What a terrible idea anyway. Here is skeets take on the question: Why is January month 0 in Java Calendar?

Why is this happening?

  • 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-04T03:23:37+00:00Added an answer on June 4, 2026 at 3:23 am

    Programmers start counting from 0. So months are represented by 0(Jan)-11(Dec).

    The reason days don’t follow this rule is to not confuse authors with 30/31 month differences.

    From MDN:

    month

    Integer value representing the month, beginning with 0 for January to
    11 for December.

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

Sidebar

Related Questions

I am speed testing some JavaScript programs by creating a Date object, and using
I created a callback when creating a new Client object instead of using the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I'm creating new Site Definitions using this method: http://weblogs.asp.net/paulballard/archive/2007/04/09/creating-a-custom-sharepoint-2007-portal-site-definition-using-the-portalprovisioningprovider-class.aspx and when they get created,
I have 2 custom fields in my WordPress system when creating new posts. One
When I'm creating new project with GWT plug in it creates a skeleton project
Can I avoid third party code from creating new threads, starting new VMs, or
I need UNION two tables with creating new field, where 1 for first table,
I need to restrict the development users from creating new schedules for SQL Agent
How can this be done more elegant and without creating new objects? List<Move> playerMoves

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.