如何在js中获取的当前时间的月份--getFullYear()、getMonth()、getDate()

1. 首先获取当前时间的月份值

   

var e= new Date()

2. 然后从当前时间获取年份跟月份进行拼接,分开始时间和结束时间(本月初到下个月月初即本个月的值)

this. startTime= e. getFullYear()+ "-"+( e. getMonth()+ 1)+ "-1";
if(( e. getMonth+ 1)== 12){
this. endTime= e. getFullYear()+ "-"+( e. getMonth()+ 1)+ "-31"
} else{
this. endTime= e. getFullYear()+ "-"+( e. getMonth()+ 1+ 1)+ "-1"
}


3.如果想获取到天

   

e. getDate()

猜你喜欢

转载自blog.csdn.net/qq_34790644/article/details/80403203