I am using a unix time stamp as the base of my starting date for use in a date ranged query. The start date is not the problem, for the purpose of this example i will use the following time stamp: 1228089600 (01 December 2008 00:00:00).
For use in my query I needed to easily figure out the last day of any given month to the last second so..
date('o-m-d G:i:s',mktime(0, 0, -1, date("m",1228089600)+1, 1, date("o",1228089600)));
This method has been working fine for me for every other month except December.. By taking the start date, adding a whole month (01 January 2009 00:00:00) then taking away 1 second I was expecting to result in the date I required (31 December 2008 23:59:59). However it appears the year is being calculated correctly for the additional month, but not for the subtracting second as the date returned is 31 December 2009 23:59:59.
As I say, this method has worked great until I discovered this problem. But it's a problem I am unable to figure out the cause of or simple solution to..
Any help is greatly appreciated.