Add 30 days to date (mm/dd/yy)

后端 未结 4 2090
耶瑟儿~
耶瑟儿~ 2020-12-03 16:59

I have a date in the format mm/dd/yy and want to add 30 days to it. I am just curious the best method to do this? I am new to javascript so examples would be he

4条回答
  •  醉梦人生
    2020-12-03 17:51

    React Answer

    Some of the Javascript commands are not available in React like getDate(). Also, I find it better to change dates to Unix timestamps so I can compare dates more easily in database searches using a simple mathematical greater than search.

    const nowPlus30Days = new Date(Date.now() + (30 * 24 * 60 * 60 * 1000)).getTime() / 1000; 
    (1597829050.184)
    

    I can compare this to today:

    const today = new Date().getTime() / 1000 
    (1595237050.184)
    

提交回复
热议问题