php怎么将当前时间戳增加一year

2026年09月29日 02:04
有3个网友回答
网友(1):

echo strtotime("+1 year"); //返回的是时间戳, 如果要转换成一般时间格式还需要下面的函数

echo date('Y-m-d H:i:s', strtotime("+1 year"));

==================================================================

同理,不仅仅可以+year 还可以是天, 月日都可以的,如下代码:

echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?>

网友(2):

date("Y-m-d")

网友(3):

date('Y-m-d H:i:s',strtotime("+1 year",strtotime("2011-3-23")))