rpaterick Posted December 10, 2010 Share Posted December 10, 2010 When I go to compose, just looking to see if there is a way to have next months last day of the month be the date that would compose. ex: If I open the FP template in January, it would then return: February, 28th 2011. Thanks Link to comment Share on other sites More sharing options...
esmith Posted December 14, 2010 Share Posted December 14, 2010 Fun, fun: var d = new Date(); var currMonth = d.getMonth(); var currYear = d.getFullYear(); // determine month and year for next month (0 = January; 11 = December)= if (currMonth == 11) { var year = currYear + 1; var month = 0; } else { var year = currYear; var month = currMonth + 1; } var monthText = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; // determine last day of next month var lastDay = new Date(new Date(year, month+1, 1)-1).getDate(); // return long date return monthText[month] + " " + lastDay + ", " + year; Link to comment Share on other sites More sharing options...
Dan Korn Posted December 14, 2010 Share Posted December 14, 2010 var d = Today(); d = new Date(d.getFullYear(), d.getMonth()+2, 0); return FormatDate(d, "lm d, yyyy"); Link to comment Share on other sites More sharing options...
esmith Posted December 14, 2010 Share Posted December 14, 2010 var d = Today(); d = new Date(d.getFullYear(), d.getMonth()+2, 0); return FormatDate(d, "lm d, yyyy"); Admit it Dan; you were waiting for me to answer so you could snub me with the 3-line solution. LOL. The advantage to my code is that it looks more complicated to your boss, assuming he doesn't know JavaScript. Link to comment Share on other sites More sharing options...
rpaterick Posted December 14, 2010 Author Share Posted December 14, 2010 Fun, fun: E, very nice! Thanks also Dan. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.