function timestampToTime(timestamp) {
var date = new Date(timestamp );//时间戳为10位需*1000,时间戳为13位的话不需乘1000
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+h+m+s;
}
本文介绍了一个简单的JavaScript函数,用于将时间戳转换为日期格式。该函数接收一个时间戳作为输入参数,并返回一个格式化的日期字符串,包括年、月、日、小时、分钟和秒。
8284

被折叠的 条评论
为什么被折叠?



