I have following code:
var d = new Date(\'2016-03-27\');
console.log(d.getDate(), d);
d.setDate(d.getDate() + 1);
console.log(d.getDate(), d);
Since you are working with UTC format dates, and you want to ignore local timezone changes such as daylight savings time, you should always use getUTCDate()
and setUTCDate()
. UTC has no daylight savings.
var d = new Date('2016-03-27');
console.log(d.getUTCDate(), d);
d.setUTCDate(d.getUTCDate() + 1);
console.log(d.getUTCDate(), d);
Also consider JavaScript date libraries such as moment.js if you have more complex requirements.