js日期转换
2021-03-03 23:26
标签:function ons div substr mon bsp ice locale 转换 1. 转换为:2020-7-9 2. 转换为2020/7/9 3. 转换为2020-07-09 11:30:23 js日期转换 标签:function ons div substr mon bsp ice locale 转换 原文地址:https://www.cnblogs.com/linliu/p/13272695.htmlvar d = new Date()
function date(date) {
var nowdate = new Date(date).toLocaleDateString().replace(/\//g, ‘-‘)
return nowdate
}
console.log(date(d));
var d = new Date()
function date(date) {
var nowdate = new Date(date).toLocaleDateString()
return nowdate
}
console.log(date(d));
var d = new Date()
function date(now) {
// var now = new Date(),
y = now.getFullYear(),
m = ("0" + (now.getMonth() + 1)).slice(-2),
d = ("0" + now.getDate()).slice(-2);
return y + "-" + m + "-" + d + " " + now.toTimeString().substr(0, 8);
}
console.log(date(d));