json日期格式转换为 2019-11-27 格式

 1         function jsonDateFormat(jsonDate) {
 2             try {
 3                 var date = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
 4                 var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
 5                 var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
 6                 var milliseconds = date.getMilliseconds();
 7                 return date.getFullYear() + "-" + month + "-" + day;
 8             } catch (ex) {
 9                 return "";
10             }
11         }

猜你喜欢

转载自www.cnblogs.com/zhuyujie/p/12795310.html