nowDate = new Date();
let date = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() + 1,
date: nowDate.getDate(),
}
console.log(date);
let systemDate = date.year + '-' + 0 + date.month + '-' + 0 + date.date;
使用格式化方法
使用js日期函数获取当前日期
var sdate=new Date();
var time2 = sdate.Format("yyyy");
var time = sdate.Format("MM");
var time2 = sdate.Format("dd");
var time = sdate.Format("hh");
var time2 = sdate.Format("mm");
var time = sdate.Format("ss");
补充
var date = new Date();
date .getYear();
date .getFullYear();
date .getMonth();
date .getDate();
date .getDay();
date .getTime();
date .getHours();
date .getMinutes();
date .getSeconds();
date .getMilliseconds();
date .toLocaleDateString();
var mytime=date .toLocaleTimeString();
date .toLocaleString( );
|