vue 循环 时间戳转换成日期
js中filters: {time: function time(value) {var d = new Date(parseInt(value) * 1000);return (d.getFullYear()) + '-' + (d.getMonth() + 1 > 9 ? d.getMonth() + 1 : '0' + (d.getMonth() + 1)) +...
·
js中
1.年月日
filters: {
time: function time(value) {
var d = new Date(parseInt(value) * 1000);
return (d.getFullYear()) + '-' + (d.getMonth() + 1 > 9 ? d.getMonth() + 1 : '0' + (d.getMonth() + 1)) + '-' + (d.getDate() > 9 ? d.getDate() : '0' + d.getDate());
}
}
2.年月日 时分秒
filters: {
time: function time(value) {
var now = new Date(value * 1000);
y = now.getFullYear();
m = now.getMonth() + 1;
d = now.getDate();
return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
}
}
页面中
{{item.input_time|time}}
更多推荐
已为社区贡献3条内容
所有评论(0)