I'm setting some future dates in Javascript like so:
var today = new Date(),
dd = today.getDate(),
mm = today.getMonth() + 1, // January is 0
yyyy = today.getFullYear(),
mmPlusThree = mm + 3,
mmPlusFour = mm + 4;
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
var todayDateString = mm + '/' + dd + '/' + yyyy,
threeMonthDateString = mmPlusThree + '/' + dd + '/' + yyyy,
fourMonthDateString = mmPlusFour + '/' + dd + '/' + yyyy;
How can I update yyyy
for threeMonthDateString
or fourMonthDateString
? Or is there a better way to get formatted strings (i.e., 12/31/2017
) of dates three and four months into the future?