php时间戳增加时间的方法

藏色散人
藏色散人原创
2023-03-05 10:12:012450浏览

php时间戳增加时间的方法:首先创建一个PHP示例文件;然后通过“strtotime("+1 year");”方法将当前时间戳增加一年的时间;最后输出增加后的结果即可。

推荐:《PHP视频教程

php当前时间戳增加时间

php将当前时间戳增加一年(year)

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

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

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

<?php
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";
?>

以上就是php时间戳增加时间的方法的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。