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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:18:48+00:00 2026-05-27T00:18:48+00:00

I am parsing a JSON object with JavaScript and displaying it in a styled

  • 0

I am parsing a JSON object with JavaScript and displaying it in a styled HTML table.

The date variable comes as a long string. (e.g. 2011-11-23 10:21:49.695805)

How can I format the date so as to be displayed: year-month-day, hour-minute instead of 2011-11-23 10:21?

The AJAX call:

$$.ajax({
    url: '/ajax/myfolder',
    dataType:"json",
    success: function(json) {
        $$('#JsonGrid').append(CreateTableView(json, "jsonFeed", true)).fadeIn();  
        parseDate();
    }     
});

function parseDate() {

}

The json object:

[{"status": "success", "date": "2011-11-23 10:21:49.695805", "user": "xy", "jobname": "jobnamexyz"}]
  • 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-27T00:18:49+00:00Added an answer on May 27, 2026 at 12:18 am

    You can use date functions, DateJS, etc., but if the format is fixed as in your example you can just take the first sixteen characters:

    var date = json["date"].substr(0,16);
    

    EDIT: sorry, just noticed you wanted a comma in there. So:

    var date = json["date"].substr(0,10) + ", " + json["date"].substr(11,5);
    

    EDIT 2: OK, try moving the call to parseDate() to before you call CreateTableView(), so you can “fix” the data before it is used. The following assumes the json is an array of objects:

    success: function(json) {
        parseDate(json);
        $$('#JsonGrid').append(CreateTableView(json, "jsonFeed", true)).fadeIn();
    
    
    function parseDate(data) {
        for (var i=0; i<data.length; i++)
            if (data[i]["date"])
                data[i]["date"] = data[i]["date"].substr(0,10)
                                + ", " + data[i]["date"].substr(11,5);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From a previous question on Stackoverflow Iterating through/Parsing JSON Object via JavaScript .... My
I'm passing a date from Ruby to Javascript via JSON. It comes into Javascript
I'm parsing a json object and populating it in table view. When the table
For a Javascript project I have an json string converted into a Javascript object.
I want to understand the basic differences clearly between JavaScript object and JSON string.
I am currently trying to pass a generated JSON string to dojo for parsing
I am parsing json object from facebook. In my facebook json object, there are
I m using ios5.i m parsing a json object and getting the values in
I'm passing a JSON object to Javascript via the ViewBag with the following code
My service returns the following JSON object, with the Content-Type header set to application/javascript.

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.