在js中时间戳为13位,通过一个js转换函数将时间戳转换为某种格式的日期。JS代码如下:
function changeDate(datetimes){
var date = new Date(datetimes);
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
// h = date.getHours() + ':';
// m = date.getMinutes() + ':';
// s = date.getSeconds();
// 年 月 日 时 分 秒
return Y+M+D;
}
如上述的时间戳为(1519903236000),转换后的日期为(2018-03-1 )