How do I take today's date and add 1 day to it?
If possible, inline please?
It is used to work with dates and times. The Date object is created by using new keyword, i.e. new Date(). The Date object can be used date and time in terms of millisecond precision within 100 million days before or after 1/1/1970.
To format a date as dd/mm/yyyy: Use the getDate() , getMonth() and getFullYear() methods to get the day, month and year of the date. Add a leading zero to the day and month digits if the value is less than 10 .
"The expression new Date() returns the current time in internal format, as an object containing the number of milliseconds elapsed since the start of 1970 in UTC.
This will get tomorrow's date:
var a = new Date((new Date()).valueOf() + 1000*3600*24);
You have to use the getDate() and setDate() methods of the Date object which respectively get and set the day value of the date.
var date = new Date(); date.setDate(date.getDate() + 1);
Check the MDC Date object reference for more information on working with dates
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