How to add weeks to date using javascript?

前端 未结 8 806
轻奢々
轻奢々 2020-12-29 18:32

Javascript definitely isn\'t my strongest point. I\'ve been attempting this for a couple of hours now and seem to be getting stuck with date formatting somewhere.

I

8条回答
  •  失恋的感觉
    2020-12-29 18:52

    Everything's there !

     date1.toLocaleDateString() 
    

    Thiswill return you date1 as a String in the client convention

    To create a new date date2 with 2 weeks more (2weeks = 2*7*24*60*60 seconds):

     var date2 = new Date(date1 + 60*60*24*7*2);
    

提交回复
热议问题