Javascript format the JSON date. The javascriptjson date
The following is the sample code.
First effect:
/// Function jsonDateFormat (jsonDate) {// convert the json date format to the normal format. try {var Date = new date (parseInt (jsonDate. replace ("/Date (",""). replace (")/", ""), 10); var month = date. getMonth () + 1 <10? "0" + (date. getMonth () + 1): date. getMonth () + 1; var day = date. getDate () <10? "0" + date. getDate (): date. getDate (); return date. getFullYear () + "-" + month + "-" + day;} catch (ex) {return "";}}
Second effect:
/// Function jsonDateFormat (jsonDate) {// convert the json date format to the normal format. try {var Date = new date (parseInt (jsonDate. replace ("/Date (",""). replace (")/", ""), 10); var month = date. getMonth () + 1 <10? "0" + (date. getMonth () + 1): date. getMonth () + 1; var day = date. getDate () <10? "0" + date. getDate (): date. getDate (); var hours = date. getHours (); var minutes = date. getMinutes (); var seconds = date. getSeconds (); var milliseconds = date. getMilliseconds (); return date. getFullYear () + "-" + month + "-" + day + "" + hours + ":" + minutes + ":" + seconds + ". "+ milliseconds;} catch (ex) {return "";}}
Summary
The above is all the content formatted by Javascript to the JSON date. Although the function is very small, it is very practical. I hope this will help you in your learning work.