php时间戳增加时间的方法

互联网 20-8-27

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时间戳增加时间的方法的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: PHP
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:php如何实现openoffice转pdf

相关资讯