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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:45:12+00:00 2026-05-16T14:45:12+00:00

Does anyone know why in Firefox if you execute the code below it will

  • 0

Does anyone know why in Firefox if you execute the code below it will validate it as a date if the string passed in is four numbers and only four numbers? In every other browser I tested with (IE, Chrome) it will always return as not a date.

Being that the spec, as pointed out by Marcel Korpel below, states that it should fall back to use the Firefox’s implementation-specific fall back I am really wondering why Firefox’s fall back displays this anomaly.

function isDate(sDate) {  
    var temp = new Date(sDate);  
    if (temp.toString() == "NaN" || temp.toString() == "Invalid Date") {  
        alert("Not a Date");  
    } else {  
        alert("Is a Date!");  
    }
}
  • 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-16T14:45:13+00:00Added an answer on May 16, 2026 at 2:45 pm

    If you pass a string to the Date constructor, the string should be in a format recognized by the parse method (IETF-compliant RFC 1123 timestamps) (source: MDC). Everything else results in implementation specific behaviour and will vary across browsers.

    I suggest you don’t use strings at all and either use three numbers representing year, month and day (mind that month numbers begin at 0 (= January)), or use one number, the number of milliseconds since 1 January 1970 00:00:00 UTC.

    UPDATE: seeing your example,

    var a = new Date('0123');
    console.log(a);
    

    outputs

    Fri Jan 01 0123 01:00:00 GMT+0100 (CET)
    

    so Firefox apparently recognizes '0123' as a year number.

    UPDATE 2: I think MDC’s description of Date.parse contains the answer to your question:

    Starting in JavaScript 1.8.5, a subset of ISO 8601 formatted date strings can also be parsed.

    The ISO 8601 page specifies (section ‘Formats’):

    Year:
    YYYY (eg 1997)
    Year and month:
    YYYY-MM (eg 1997-07)
    Complete date:
    YYYY-MM-DD (eg 1997-07-16)

    So when relying on ISO 8601, a string only containing four numbers will be recognized as a year number.

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

Sidebar

Related Questions

Does anyone know why the following code does not work in FireFox but does
Does anyone know when or if other browsers like Firefox and IE will allow
Does anyone know of a firefox plugin that allows you to view what a
Does anyone know a way to get Firefox to crop the corners if the
Does anyone know what the q factor HTTP headers emitted by Firefox 3 mean?
Does anyone know if there is some type of tool, preferably a Firefox add
Does anyone know if there is a way to generate different code in the
Does anyone know if Firefox extensions are allowed to modify HTTP response headers? For
Does anyone know how to obtain the browser culture from Firefox and Google Chrome
Does anyone know why this CSS selector works in Firefox but not in IE7

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.