Home  >  Article  >  Web Front-end  >  How to display time in json format as normal year, month and day_javascript skills

How to display time in json format as normal year, month and day_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:23:051388browse

The time in json format is displayed as: /Date(1377828670436)/ needs to be converted to normal year, month and day, the method is as follows:

Copy code The code is as follows:

//If the json converted through serialization contains DateTime format, the time will not be displayed normally. Just use the following method.
var date=renderTime (json.AddDateTime);
//Pass the read json format time into this method
function renderTime(date){
var da = new Date(parseInt(date.replace("/Date (","").replace(")/","").split(" ")[0]));
return da.getFullYear() "-" (da.getMonth() 1) " -" da.getDate() " " da.getHours() ":" da.getSeconds() ":" da.getMinutes();
}
//The format of the last displayed time is 2012-4- 17 22:58
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn