1

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 ?

Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
  • 2
    possible duplicate of [JavaScript how to get tomorrows date in format dd-mm-yy](http://stackoverflow.com/questions/9444745/javascript-how-to-get-tomorrows-date-in-format-dd-mm-yy) – Brendan Bullen Jul 04 '13 at 13:41
  • 2
    Check http://stackoverflow.com/questions/9444745/javascript-how-to-get-tomorrows-date-in-format-dd-mm-yy – GoldenTabby Jul 04 '13 at 13:43

4 Answers4

7
var todayDate = new Date();

todayDate .setDate(todayDate .getDate() + 1);

Then todayDate contains tomorrow date

PSR
  • 39,804
  • 41
  • 111
  • 151
1

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)

Brendan Bullen
  • 11,607
  • 1
  • 31
  • 40
0
var d = new Date();
d.setDate(d.getDate() + 1)
console.log(d)
Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68
0

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");

Docs: http://momentjs.com/docs/

gustavohenke
  • 40,997
  • 14
  • 121
  • 129