PHP:将时间添加到时间戳 [英] PHP: Adding years to a timestamp

查看:134
本文介绍了PHP:将时间添加到时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP中给出了UTC时间戳,我想添加几个N年。这应该考虑到闰年。



谢谢。

解决方案

  $ newTimestamp = strtotime('+ 2年',$ timestamp); 

根据需要替换+2年。



参考: http://php.net/manual/en/function.strtotime。 php


In PHP given a UTC timestamp I would like to add exactly N number of years. This should take into consideration leap years.

Thank you.

解决方案

$newTimestamp = strtotime('+2 years', $timestamp);

Replace "+2 years" as required.

ref: http://php.net/manual/en/function.strtotime.php

这篇关于PHP:将时间添加到时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆