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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:49:58+00:00 2026-06-11T18:49:58+00:00

(EDIT: I am using chrome console for the code below) I realize that javascript

  • 0

(EDIT: I am using chrome console for the code below)

I realize that javascript Date() is deprecated, but it’s useful for something I’m currently working on; however there is a strange problem:

var x = new Date('999').getFullYear()

returns 999

while

var x = new Date('1000').getFullYear()

returns 999 as well, but

var x = new Date('10000').getFullYear()

returns 10000…

Does anyone know why do 4 digit numbers give the wrong .getFullYear()?

  • 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-11T18:49:59+00:00Added an answer on June 11, 2026 at 6:49 pm

    As the other answers suggest, you can’t rely on Date.parse across browsers, especially if you are dealing with dates before 1000 CE.

    As far as Chrome is concerned, it looks like the issue is how the browser deals with timezones. The following example suggests that before 1000 CE, Chrome parses the date in your local timezone on top of it; >= 1000 CE, it appears to first parse the date in UTC, then applies the timezone conversion:

    > new Date('1000')
    "Tue Dec 31 999 16:00:00 GMT-0800 (PST)"
    > new Date('999')
    "Tue Jan 01 999 00:00:00 GMT-0800 (PST)"
    

    I’d be inclined to see this as a bug, but perhaps the Chromium team thinks it’s a feature :).

    The bottom line is that, if you want accurate date parsing for years, especially ancient years, you need to do some work yourself and/or use a library. Moment.js and Datejs both might help, but I doubt either deals well with ancient years. Moment.js seems to have the same issue (in Chrome):

    > moment('999').year()
    999
    > moment('1000').year()
    999
    

    The best way I know of to accurately set dates based on ancient years is generally to a) always use UTC, and b) set the date manually:

    var d = new Date();
    d.setUTCFullYear('999');
    d.getUTCFullYear(); // 999
    d.setUTCFullYear('1000');
    d.getUTCFullYear(); // 1000
    

    In Chrome at least, this works with both strings and integers.

    You might also be interested in the gregorian parser in the Timemap.js library, which handles ancient years with AD, CE, BC, and BCE extensions, as well as negative numbers.

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

Sidebar

Related Questions

I have a text file that I want to edit using Java. It has
EDIT: iam using ajax to load text in my content that is why onload
I'm using Visual Studio 2008. I'm currently working with WPF and I'm using Edit->Format
I am using Komodo Edit , a code editor. When I right click on
I've been using Komodo Edit for a small project in Django. The code completion
I'm currently working on a table application heavily coded in javascript using jQuery. When
I would like to debug my javascript application using Google Chrome 3 's developer
I'm working on Javascript code that uses XMLHttpRequest to POST to a server. My
I'm using this edit-in-place widget jquery.jeditable.js . On Windows 7, in Chrome (latest version
Given a std record edit form using WPF two way binding to a EF

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.