stay C# The date will be transferred to the front end in the background and the display will appear /Date(1545299299910)/
This format , This is a kind of JSON Timestamp format for , However, it is obviously inappropriate to use this date format as a front-end display , At this time, we have to deal with it in the front end .
The processing code is as follows :
//val Is the timestamp to be processed function DateFormat(val) { if (val != null) { // Get timestamp part as : obtain
/Date(1545299299910)/ Medium 1545299299910 part var date = new
Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10));
// Month is 0-11, therefore +1, Month less than 10 Time to make up 0 var month = date.getMonth() + 1 < 10 ? "0" +
(date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() <
10 ? "0" + date.getDate() : date.getDate(); var currentTime = date.getHours() <
10 ? "0" + date.getHours() : date.getHours(); var minutes = date.getMinutes() <
10 ? "0" + date.getMinutes() : date.getMinutes(); var seconds =
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
// Format display , In the shape of :2018-12-20 17:48:19 return date.getFullYear() + "-" + month + "-" +
currentDate + " " + currentTime + ":" + minutes + ":" +seconds; } return ""; }
Technology