JS 前端获得时间

时间:2021-08-16 10:29:28   收藏:0   阅读:10

//获取系统当前时间

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;

原文:https://www.cnblogs.com/hehuarong/p/15146155.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!