I have timestamp in DB like: 1268085720, its 2010-03-08 23:00, so its today.
How can i add one year, and to be the last day in the same month, and need to convert it like: YYYY-MM-DD HH:MM?
For given example i need 2011-03-31 23:59.
Thanks
I have timestamp in DB like: 1268085720, its 2010-03-08 23:00, so its today.
How can i add one year, and to be the last day in the same month, and need to convert it like: YYYY-MM-DD HH:MM?
For given example i need 2011-03-31 23:59.
Thanks
Use mktime();
$time=1268085720;
$nextyear=mktime(date('h', $time), date('i', $time), date('s', $time), date('m', $time), date('t', $time), date('Y', $time)+1);
//$result contain the timestamp
$lastday=strtotime('+1 year', $result);
echo date('Y-m-t H:i',$lastday);
here :)
Modification of http://stackoverflow.com/questions/1686724/php-last-day-of-the-month
echo date("Y-m-t 23:59:59", strtotime("+1 year", 1268085720));
// -> 2011-03-31 23:59:59
The t
format gives the number of days in the given month (28 through 31). If you want the real hours and minutes, use Y-m-t H:i:s
instead of the hardcoded time.