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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:54:48+00:00 2026-06-12T16:54:48+00:00

Possible Duplicate: How can I convert string to datetime with format specification in JavaScript?

  • 0

Possible Duplicate:
How can I convert string to datetime with format specification in JavaScript?

I have a json response which contains a hashmap like;

{"map":{"2012-10-10 03:47:00.0":23.400000000000002,"2012-10-10 03:52:00.0":23.3,"2012-10-10 03:57:00.0":23.3,"2012-10-10 04:02:00.0":23.3,"2012-10-10 04:07:00.0":23.200000000000003,"2012-10-10 04:13:00.0":23.1,"2012-10-10 04:18:00.0":23.1,"2012-10-10 04:23:00.0":23.0,"2012-10-10 04:28:00.0":23.0,"2012-10-10 04:33:00.0":23.0,"2012-10-10 04:38:00.0":22.900000000000002,"2012-10-10 04:43:00.0":22.8,"2012-10-10 04:48:00.0":22.8,"2012-10-10 04:53:00.0":22.700000000000003,"2012-10-10 04:58:00.0":22.6,"2012-10-10 05:03:00.0":22.6,"2012-10-10 05:08:00.0":22.5,"2012-10-10 05:13:00.0":22.5,"2012-10-10 05:18:00.0":22.5,"2012-10-10 05:23:00.0":22.400000000000002}}

I want to format datetime part of json like;

dd/mm/yyyy HH:mm:ss

Lets assume I put all pair elements like this;

var myArr = [["2012-10-10 03:47:00.0", 23.400000000000002], ["2012-10-10 03:52:00.0", 23.3], ....];

Then, I try to parse datetime part like below and I got Date {Invalid Date} on console;

new Date(myArr[0][0]);

How can I format this type of datetime.

  • 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-12T16:54:49+00:00Added an answer on June 12, 2026 at 4:54 pm

    Try the following:

    new Date(Date.parse(myArr[0][0]));
    

    EXAMPLE

    Use the Date.parse method to parse the string into the number of milliseconds since January 1, 1970, 00:00:00 UTC. Take that number of milliseconds and call the Date method once again to turn that time into a date object.

    EDIT:

    Well this may be a little ugly for this case, but it seems Firefox is having an issue with the -s and the 00.0.

    var myArr = [["2012-10-10 03:47:00.0", 23.400000000000002], ["2012-10-10 03:52:00.0", 23.3]];
    
    var date = convertDateTime(myArr[0][0]);
    console.log(date);
    
    function convertDateTime(dateTime){
        dateTime = myArr[0][0].split(" ");
    
        var date = dateTime[0].split("-");
        var yyyy = date[0];
        var mm = date[1]-1;
        var dd = date[2];
    
        var time = dateTime[1].split(":");
        var h = time[0];
        var m = time[1];
        var s = parseInt(time[2]); //get rid of that 00.0;
    
        return new Date(yyyy,mm,dd,h,m,s);
    }
    

    EXAMPLE

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

Sidebar

Related Questions

Possible Duplicate: How can I convert a string to boolean in JavaScript? I have
Possible Duplicate: How can I convert datetime microformat to local time in javascript? Im
Possible Duplicate: how can I convert String to Int ? Hi, I have the
Possible Duplicate: Javascript date sorting by convert the string in to date format I
Possible Duplicate: How can I convert a string to boolean in JavaScript? Hi, How
Possible Duplicate: How to convert string as object's field name in javascript I can
Possible Duplicate: How can I convert String to Int? public List<int> GetListIntKey(int keys) {
Possible Duplicate: convert string to 2D array using php I have the string like
Possible Duplicate: Convert string to DateTime in c# A question I got a string
Possible Duplicate: Can't convert String into integer in ruby/ruby-on-rails I'm running through a tutorial

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.