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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:58:37+00:00 2026-06-06T20:58:37+00:00

This works in Chrome: var dateArray = [2012, 6, 5]; var dateObject = new

  • 0

This works in Chrome:

var dateArray = [2012, 6, 5];
var dateObject = new Date(dateArray);

And I get June 5, 2012. I also tried on an Android browser and I get the same results. However, the same does not work in Firefox or Safari. I could say:

var dateObject = new Date(2012, 6, 5);

But that would be July 5, 2012, as it should, and is also what I get with Chrome.

My question: is the first example part of the ECMA standard? Is it just that Chrome is more bleeding edge and could I expect other browsers to support it in the future? Or is it just some v8-ism that I should avoid for portability?

I’ve been trying to find references for this specific form of the Date constructor but could not get any.

  • 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-06T20:58:39+00:00Added an answer on June 6, 2026 at 8:58 pm

    The ES5 spec details the new Date(value) form of the Date constructor. In the algorithm for handling this form, value is converted to a primitive value by calling the [[DefaultValue]] internal method of the object.

    Converting an array to a primitive value is basically done by converting the array to a string. Converting an array to a string (Array.prototype.toString) is effectively the same as calling dateArray.join().

    Therefore, your call to the Date constructor will effectively look like this:

    var dateObject = new Date("2012,6,5");
    

    If the string can be recognised by the Date.parse method, you will end up with a Date instance.

    This form of the Date constructor is also listed on MDN as new Date(dateString).

    Firefox seems to fail when you pass an array, but it succeeds if you pass the string representation of that array. I would say that that’s probably a Firefox bug, but I may be misinterpreting the ES5 spec.

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

Sidebar

Related Questions

In Firefox's and Chrome's consoles, this works (alerts script content): var script = document.createElement(script);
I have this in my JavaScript var identifier = event.target.id; it works on Chrome
var obj = { destroy: function(){this = null;} }; obj.destroy(); This works in Chrome,
This code works perfectly in Chrome, but is blank in mobile Safari. Tried to
This works in modern Chrome/Firefox/Opera but fails in IE8. Haven't tried it in IE9.
$.post($(this).attr(action), $(this).serialize(), function(json) { alert('red'); AddItemAjax(json); }, json); This works in Chrome but not
This works in Firefox and Chrome, but fails in IE. It does show results
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
Yeah this works in FF and Chrome, but for some reason wont work in
I'm trying to figure out why this works in FireFox, Chrome but not in

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.