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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:12:25+00:00 2026-05-27T20:12:25+00:00

I have an old web app where Javascript is used to validate some dates.

  • 0

I have an old web app where Javascript is used to validate some dates. Users usually use 2-digit years and I recently discovered it was evaluating 00 as 1900 instead of 2000

if (new Date(tb[0].value) > new Date(tb[1].value)){
    alert('Starting date must come before the ending date');
    tb[0].focus();
    return false;
}

Entering 1/1/99 in the first box and 1/1/00 in the 2nd will cause an error message saying the start date has to be before the end date because 99 is evaluating at 1999 while 00 is evaluating at 1900.

Of course, Users can get around this using 4-digit years, but I still want to know what can be done to get Javascript to evaluate 2-digit years correctly.

So my question is, how can I get Javascript to evaluate 00 as 2000 and not 1900?

  • 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-27T20:12:26+00:00Added an answer on May 27, 2026 at 8:12 pm

    It does that because the language was created in the 1990’s (and in a hurry). You can use getFullYear() and setFullYear() to handle years in a non-goofy way.

    What I’ve done is write some code to check for year values less than 100, and if it’s greater than 90 (or something similarly appropriate, depending on the situation) assume it’s in the 20th century, otherwise assume the 21st.

    And @Rachel no there’s no way to tell the runtime library to behave differently, at least not any standardized way. That’s just how the Date code works.

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

Sidebar

Related Questions

We have an old web app written in classic ASP. We don't have the
I have a site a few years old that contains about 30 aspx Web
I have a Django web app that I would like to use in a
I have created a web app that authenticates users on our page and I'd
For some strange reason, a five year old internal asp.net web app that is
I have a bunch of code in my old Web Forms app I'm migrating
I have an existing asp.net web app that uses facebook to authenticate users. I
I have in here an old web application written in ASP.Net 2.0 + AJAX.
I have several horrors of old ASP web applications. Does anyone have any easy
Scenario: old legacy code in rpg have to consume data from a new web

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.