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

  • SEARCH
  • Home
  • 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 5954099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:55:20+00:00 2026-05-22T17:55:20+00:00

I have noticed that the jQuery function New Date() does something odd. I have

  • 0

I have noticed that the jQuery function New Date() does something odd. I have already found a way to work around it so I don’t need help. I just want to understand why it is doing this.

I have a function doing the following:

new Date(parseInt(y),parseInt(m)-1,parseInt(d))

the actual numbers are: y= '2011', m= '07', d='01'. This works fine, it returns the date 1/7/2011. But when I use m= '08' it returns “Wed Dec 01 2010”

I tracked it down to the parseInt function. Somehow parseInt('07') = 7 but parseInt('08') = 0
Does anyone know why this happens?

  • 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-05-22T17:55:21+00:00Added an answer on May 22, 2026 at 5:55 pm

    First New Date() is not a jQuery function, but plain JavaScript.

    Unfortunately, JavaScript borrowed a lot from the language C, in which you write octal numbers by prepending a zero in front of it. Octal numbers a numbers which go from 0 to 7.

    What you have to do, and is best practice, is to say you have decimal numbers, not octal.

    Always give the radix: parseInt(y, 10), so you code will be:

    new Date(parseInt(y, 10),parseInt(m, 10)-1,parseInt(d, 10))
    

    More info about parseInt:

    https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt

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

Sidebar

Related Questions

I have noticed that sometimes people have to use multiple versions of jQuery in
I have noticed that regardless of a given script's execution time, every date() call
I currently have a jQuery function that replaces an image when clicked. For instance:
Have you noticed that every 10 questions on this site is about jQuery? Anyway...
I'm helping a company develop a website that utilizes jquery but I have noticed
I noticed that some jQuery buttons inside a container don't work when they are
I have been playing around with a search control and i have noticed that
I created some widgets with jQuery UI and I notice that buttons have a
I have noticed that cURL in PHP returns different data when told to output
I have noticed that some apps like Safari and Mail show a loading indicator

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.