I am using a rather nice iPhone date control for a iPhone only website I am developing: http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch
One of the wheels I want to create is basically the next 6 months with the month and year displayed. To hard code this I used:
var monthsYears = {
'05-2010': 'Jun 2010',
'06-2010': 'Jul 2010',
'07-2010': 'Aug 2010',
'08-2010': 'Sep 2010',
'09-2010': 'Oct 2010',
'10-2010': 'Nov 2010'
};
If I take the first one '05-2010': 'Jun 2010'
05 is the month value 2010 is the year and Jun is the month name
But obviously this is no use as it isn’t going to work next month! But I’m stumped how to get this to work dynamically. Any help appreciated.
The following should avoid problems when adding a month to the last day of a month ending on a 31st: