JS 前端获得时间

//获取系统当前时间

var nowdate = new Date();

var y = nowdate.getFullYear();

var m = nowdate.getMonth()+1;

var d = nowdate.getDate();

var formatnowdate = y+'-'+m+'-'+d;

 

//获取系统前一个月的时间

nowdate.setMonth(nowdate.getMonth()-1);

var y = nowdate.getFullYear();

var m = nowdate.getMonth()+1;

var d = nowdate.getDate();

var formatwdate = y+'-'+m+'-'+d;

上一篇:C语言:实验11-1-2 输出月份英文名.2021-08-06


下一篇:浅谈ES6中的Class