I'm trying to create a JS code which displays tthe tomorrow's date. This is the code I tried :
var d = new Date.today().addDays(1).toString("dd-mm-yyyy");
but it won't work for me.
How can I solve it ?
I'm trying to create a JS code which displays tthe tomorrow's date. This is the code I tried :
var d = new Date.today().addDays(1).toString("dd-mm-yyyy");
but it won't work for me.
How can I solve it ?
var todayDate = new Date();
todayDate .setDate(todayDate .getDate() + 1);
Then todayDate
contains tomorrow date
Try this :
var d = new Date();
var tomorrowDate = d.getDate() + 1;
d.setDate(tomorrowDate);
document.write("Tommorow date : " + d );
Output :
Tommorow date : Fri Jul 05 2013 19:16:50 GMT+0530 (IST)
If you're going to deal a lot with dates, I'd recommend you to use Moment.js. It allows you to do exactly what you want, aswell much more things:
var date = moment().add("days", 1);
// If displaying this date, use the following to format it in your culture.
// Will be mm-dd-yyyy in en-US, I believe
date.format("L");