PHP怎么往一个时间戳参数上加上一年的时间长度呢?
PHP怎么往一个时间戳参数上加上一年的时间长度呢?
PHP怎么往一个时间戳参数上加上一年的时间长度呢?
PHP怎么往一个时间戳参数上加上一年的时间长度呢?
PHP怎么往一个时间戳参数上加上一年的时间长度呢?
$a = 1525020962;;// a是一个时间戳
$b = strtotime('+1 year',$a);//b是 时间戳a 加一年后得到的 时间戳
echo date('Y-m-d H:i:s',$b);
echo strtotime("+1 year"); //返回的是时间戳, 如果要转换成一般时间格式还需要下面的函数
echo date('Y-m-d H:i:s', strtotime("+1 year"));
echo 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";
?>
//字符串转时间戳
echo strtotime("+1 year"); //返回的是时间戳, 如果要转换成一般时间格式还需要下面的函数
//格式化时间戳
echo date('Y-m-d H:i:s', strtotime("+1 year"));
你可以直接在原来的时间戳加上365*24*60*60!然后在转化回时间格式!