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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:18:25+00:00 2026-06-13T13:18:25+00:00

I have a system that returns a JSON object that contains dates in string

  • 0

I have a system that returns a JSON object that contains dates in string format.

These dates are in the format “2012-10-19 06:05:38 GMT” (no… I’m stuck with them like this)

So I need to get this into a date object (d) ready to output as d.toLocaleDateString()

In chrome it works perfectly by just passing the string to a new Date (Bad bad Chrome – makes Eric lazy), but of course it fails in FF and IE

I can fix it by splitting the string but its not pretty and I’ve not figured out dealing with the offsets from GMT.

There must be a more elegant way…?

I’m sure someone here can do it in one line.

  • 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-13T13:18:26+00:00Added an answer on June 13, 2026 at 1:18 pm

    It’s not quite a one-liner, but if you know all your dates will be GMT, something like the following should work:

    function parseDate(dateString) {
        // [y, m, d, hr, min, sec]
        var parts = dateString.match(/\d+/g);
    
        // Months are 0-indexed
        parts[1] -= 1;
    
        return new Date(Date.UTC.apply(Date, parts));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have controller GET action that returns a JSON-serialized dictionary. The
I have rest controllers that returns Json response. I have added interceptor which will
I have a WCF service that returns JSON to the clients. This is the
We have system here that uses Java JNI to call a function in a
I have a system that takes dynamic data, puts it in HTML for layout
I have big system that make my system crash hard. When I boot up,
I have a system that runs like this: main.exe runs sub.exe runs sub2.exe and
I have a system that will generate messages sporadically, and I would like to
We have a system that has some Bash scripts running besides Java code. Since
We have a system that runs in IIS. The system should always run using

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.