1.获取当前日期
getNowData(){
let data = new Data();
let year = data.getFullYear();//年
let month = date.getMonth() + 1; //月
let strDate = date.getDate(); //日
//数字前面加"0"
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
nowData = year + "-" + month + "-" + strDate;
}
2.获取当期的日期时间
getNowData(){
let data = new Data();
let year = data.getFullYear(); //年
let month = date.getMonth() + 1; //月
let strDate = date.getDate(); //日
let hh = now.getHours(); //时
let mm = now.getMinutes(); //分
let ss = now.getSeconds(); //秒
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
if(hh>=0&&hh<=9){
hh="0"+hh;
}
if(mm>=0&&mm<=9){
mm="0"+mm;
}
if(ss>=0&&ss<=9){
ss="0"+ss;
}
nowData = year + "-" + month + "-" + strDate+" "+hh+":"+mm+":"+ss;
}