How to get last day of the month

后端 未结 9 1000
闹比i
闹比i 2021-02-01 20:37

How can I obtain the last day of the month with the timestamp being 11:59:59 PM?

9条回答
  •  执念已碎
    2021-02-01 21:18

    var d = new Date();
    m = d.getMonth(); //current month
    y = d.getFullYear(); //current year
    alert(new Date(y,m,1)); //this is first day of current month
    alert(new Date(y,m+1,0)); //this is last day of current month   
    

提交回复
热议问题