当前位置:Gxlcms > 数据库问题 > 用js转换joson返回数据库的时间格式为/Date(*************)/

用js转换joson返回数据库的时间格式为/Date(*************)/

时间:2021-07-01 10:21:17 帮助过:5人阅读

function ChangeDateFormat(val) { 2 if (val != null) { 3 var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10)); 4 //月份为0-11,所以+1,月份小于10时补个0 5 var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; 6 var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); 7 return date.getFullYear() + "-" + month + "-" + currentDate; 8 } 9 10 return ""; 11 }

用js转换joson返回数据库的时间格式为/Date(*************)/

标签:

人气教程排行