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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:59:41+00:00 2026-06-06T18:59:41+00:00

I am taking a date from a JSON object in the format of 2012-12-31

  • 0

I am taking a date from a JSON object in the format of 2012-12-31 and trying to convert it into friendly values and output it.

    var redeemableDate = item.Deal.RedeemableDate; //this is coming in the form of 2012-12-31
    var redeemableDate = new Date(redeemableDate);
    var rdDay = weekday[redeemableDate.getDay()]; //using an array with weekdays
    var rdDate = redeemableDate.getDate();
    var rdMonth = monthNames[redeemableDate.getMonth()]; //using an array with month names
    var rdYear = redeemableDate.getFullYear();

    response.write('Valid ' + rdDay + ' ' + rdDate + ' ' + rdMonth + ' ' + rdYear + ' ONLY');

It all works find and dandy in Firefox and Chrome, but Safari and IE (only tested on IE8 so far) don’t like it.

In FF and Chrome I get the expected:

Valid Sunday 2 September 2012 ONLY

But in Safari and IE, I get:

Valid undefined NaN undefined NaN ONLY

When I alert redeemableDate after I have set it as a Date object, Safari returns ‘Invalid Date’ and IE returns ‘NaN’. This is obviously where the issue lies. Is there a way I can get my value into a date object for these browsers?

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

    The yyyy-mm-dd (ISO 8601) date format is not supported in Safari and IE. It is part of ECMAscript 5 though, so it should be just a matter of time.

    A solution would be to pass the date in as arguments to Date.

    var date = "2012-12-31".split("-");
    var your_date = new Date(date[0], date[1]-1, date[2]);
    

    Note that month parameter starts at zero (for January), so you must subtract 1 from the value obtained from the string.

    EDIT:
    For a shortcut see answer by joe larson below.

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

Sidebar

Related Questions

I am taking a javascript new Date() and trying to format it as a
So I need to convert a date to a different format. With a bash
I am trying to get values from a view which i have the code
in my Android application, i am taking date and time from database. but i
I have two input dates taking from Date Picker control. I have selected start
I am taking datas from the users and storing into the database. My database
I have a hourly dataset from 1996 - 2010 in the following format: date
I need to do a date comparison in Mysql without taking into account the
I need to set a date that would be 30 days from now taking
I have ssis package in that I'm taking values from flat file and insert

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.