Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:23:05
Original
1405 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!