Probably been done to death but right now I cant find anything on adding a variable number of months to a date?
I need to list records that have a date appearing within the next ‘X’ months. So the user could input 1 months or 60 months etc. and I need to list only those records which have dates falling within the time period between today and ‘X’ months hence.
Not sure about the approach that’s sensible for this one - the conversion to milliseconds is obviously wrong because we don’t know how long the calendar months are and updating the number of months cause problems when it goes over 12 (without further processing to update the years).
I suspect there is some functionality already available for this???
Working with dates is always pretty complex. The very reason why other developers already made (free) plugins/libraries that make it easier for you like the following:
Working with dates is always pretty complex. The very reason why other developers already made (free) plugins/libraries that make it easier for you like the following:
I myself use the mod_datejs a lot. Adding 60 months is just a matter of myDate.addMonths(60) and myDate is 60 months further.
Hope this helps.
Thanks Robert - I’d forgotten that I had that module already in place (mod_datejs) because of the gantt! That’s a big set of date function. Is there any documentation on it Robert with reference to the functions available - specifically the formatting options etc? I see there is a lot of code to review and study - I noticed that the formatting is necessary to coincide with the Db I’m using at the moment.