标签:页面 时间戳 timestamp ret nbsp 日期 function mon span
1 // 时间戳转换成日期 2 function timestampToTime(timestamp) { 3 var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 4 Y = date.getFullYear() + ‘-‘; 5 M = (date.getMonth() + 1 < 10 ? ‘0‘ + (date.getMonth() + 1) : date.getMonth() + 1) + ‘-‘; 6 D = date.getDate() + ‘ ‘; 7 h = date.getHours() + ‘:‘; 8 m = date.getMinutes() + ‘:‘; 9 s = date.getSeconds(); 10 return Y + M + D + h + m + s; 11 } 12 13 14 // 页面输出时间 15 document.write(timestampToTime(1234567980123));
标签:页面 时间戳 timestamp ret nbsp 日期 function mon span
原文地址:https://www.cnblogs.com/lprosper/p/9313510.html