如果你不多说,看看代码:
获取今天
无功nowdate =新(
日期); / /日期
console.log(nowdate);
今天是本周的头几天。
无功nowdayofweek = nowdate.getday();
console.log(nowdayofweek);
当前日期
今天,nowdate.getdate(VAR);
console.log(时代);
当前月份
无功nowmonth = nowdate.getmonth();
console.log(nowmonth);
当前年份
无功nowyear = nowdate.getfullyear();
console.log(nowyear);
/ /无功nowhours = nowdate.gethours();
/ /无功nowminutes = nowdate.getminutes();
/ /无功nowseconds = nowdate.getseconds();
nowyear =(nowyear<2000)1900:0; / /
console.log(nowyear);
无功lastmonthdate =新(日期); / /日期的最后一个月
console.log(lastmonthdate);
(1)lastmonthdate.setdate;
console.log(lastmonthdate.setdate(1));
lastmonthdate.setmonth(lastmonthdate.getmonth)-(1);
console.log(lastmonthdate.setmonth(lastmonthdate.getmonth)-(1));
去年lastmonthdate.getyear(VaR)=;
console.log(去年);
上个月,lastmonthdate.getmonth(VAR);
console.log(上个月);
/ /日期格式:yyyy-mm-dd
功能formatDate(日期){
无功myyear = date.getfullyear();
无功mymonth = date.getmonth()+ 1;
无功myweekday = date.getdate();
/ /无功时间= date.gethours();
/ /无功myminutes = date.getminutes();
/ /无功myseconds = date.getseconds();
如果(mymonth<10){
mymonth =0+ mymonth;
}
如果(myweekday<10){
myweekday =0+ myweekday;
}
/ /如果(时间<10){
/ /时间= 0 +时间;
/