Skip to content Skip to sidebar Skip to footer

How Date Format Is Converted To Json

Can you any one explain this date format . This is my table id=8 data (I am not understanding this format): id=8|startTime=1900-02-20 00:00:00|endTime=1900-02-20 00:00:00

Solution 1:

You need to store JSON object to a variable to use its properties to create Date object, because this JSON object is not of Date type. You can use any constructor from the JavaScript Dates.

And I want this format only .....(yyyy-MM-dd)

You can use time property.

var json = {"endTime": {
               "date": 20,
               "day": 5,
               "hours": 0,
               "minutes": 0,
               "month": 1,
               "seconds": 0,
               "time": 1424370600000,
               "timezoneOffset": -330,
               "year": 115 
             }
           };


document.getElementById("demo").innerHTML = newDate(json.endTime.time).toLocaleFormat("%Y-%m-%d");

JSFiddle

Post a Comment for "How Date Format Is Converted To Json"