Today's date in MM/DD/YYYY:
// today's date
var d = new Date();
var month = d.getMonth() + 1;
var day = d.getDate();
var year = d.getFullYear();
var vdate = month + "/" + day + "/" + year;
Last day of the next month:
// last day of next month
if (d.getMonth() + 1 == 12) {
var nmonth = 1;
var nyear = d.getFullYear() + 1;
var lastday = new Date(nyear, 1, 0).getDate();
}
else {
var nmonth = d.getMonth() + 2;
var nyear = d.getFullYear();
var lastday = new Date(nyear, d.getMonth() + 2, 0).getDate();
}
var expdate = nmonth + "/" + lastday + "/" + nyear;
There are a dozen ways to get to this result and always interested in other ways to get the same info.
No comments:
Post a Comment