How to add weeks to date using javascript?

前端 未结 8 847
轻奢々
轻奢々 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

    This might not answer the question per se, but one can find a solution with these formulas.

    6.048e+8 = 1 week in milliseconds

    Date.now() = Now in milliseconds

    Date.now() + 6.048e+8 = 1 week from today

    Date.now() + (6.048e+8 * 2) = 2 weeks from today

    new Date( Date.now() + (6.048e+8 * 2) ) = Date Object for 2 weeks from today

提交回复
热议问题