我的数据库时间戳如下:1268085720,现在是2010-03-08 23:00,所以今天就是这样。
如何添加一年,并成为同月的最后一天,需要将其转换为:YYYY-MM-DD HH:MM?
对于给定的例子,我需要2011-03-31 23:59。
答案 0 :(得分:1)
How to find the last day of the month from date?
的修改echo date("Y-m-t 23:59:59", strtotime("+1 year", 1268085720));
// -> 2011-03-31 23:59:59
t
格式给出了给定月份(28到31)的天数。如果您想要实际的小时和分钟,请使用Y-m-t H:i:s
代替硬编码时间。
答案 1 :(得分:0)
使用mktime();
$time=1268085720;
$nextyear=mktime(date('h', $time), date('i', $time), date('s', $time), date('m', $time), date('t', $time), date('Y', $time)+1);
答案 2 :(得分:0)
//$result contain the timestamp
$lastday=strtotime('+1 year', $result);
echo date('Y-m-t H:i',$lastday);
这里:))