You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
|
|
function getT(){
|
|
const temore = new Date().getTime() + 1000 * 60 * 60 * 24
|
|
const now = new Date(temore)
|
|
let year = now.getFullYear(); //得到年份
|
|
let month = now.getMonth();//得到月份
|
|
let date = now.getDate();//得到日期
|
|
return new Date(year + "-" + month + "-" + date).getTime()
|
|
}
|
|
function transformT(t){
|
|
let now = new Date(t);
|
|
let year = now.getFullYear(); //得到年份
|
|
let month = now.getMonth();//得到月份
|
|
let date = now.getDate();//得到日期
|
|
let day = now.getDay();//得到周几
|
|
let hour = now.getHours();//得到小时
|
|
let minu = now.getMinutes();//得到分钟
|
|
let sec = now.getSeconds();//得到秒
|
|
let MS = now.getMilliseconds();//获取毫秒
|
|
let week;
|
|
month = month + 1;
|
|
if (month < 10) month = "0" + month;
|
|
if (date < 10) date = "0" + date;
|
|
if (hour < 10) hour = "0" + hour;
|
|
if (minu < 10) minu = "0" + minu;
|
|
if (sec < 10) sec = "0" + sec;
|
|
if (MS < 100)MS = "0" + MS;
|
|
let time = "";
|
|
time = year + "-" + month + "-" + date + " " + hour + ":" + minu + ":" + sec;
|
|
return time
|
|
}
|
|
|
|
console.log(transformT(getT())) |