I need to set a date that would be 30 days from now taking into account months that are 28,29,30,31 days so it doesn't skip any days and shows exactly 30 days from now. How can I do that?
value = (date. getMonth() + 1) + '/' + date. getDate() + '/' + date. getFullYear();
The static Date.now() method returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
The date. now() method is used to return the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC. Since now() is a static method of Date, it will always be used as Date. now().
The JavaScript "Date()" object has got you covered:
var future = new Date();
future.setDate(future.getDate() + 30);
That'll just do the right thing. (It's a little confusing that the getter/setters for day-of-month have the names they do.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With