php日期操作方法

<?php
/**
* PHP里的日期加减方法
*/
// 第一步,假设有一个时间
$a = '2012-04-25 10:10:00';
// 第二步,获得这个日期的时间戳
$a_time = strtotime($a);
// 第三步,获得加五个月后的时间戳
$b_time = strtotime('+5 Month',$a_time);
// 第四部,把时间戳转换回日期格式
$b = date('Y-m-d H:i:s',$b_time);
echo '这是加了五个月后的日期'.$b;
// 如果你觉得以上代码过长也可以一行搞定
$b = date('Y-m-d H:i:s',strtotime('+'.$time.' Month',strtotime($a)));
echo '这是加了五个月后的日期'.$b;
?>
//PHP 日期 加减 天
 date("Y-m-d",strtotime("2013-11-12 12:12:12 +1 day"))  ;

//PHP 日期 加减 天
 date("Y-m-d",strtotime("2013-11-12 12:12:12 +1 month"))  ;


//PHP 日期 加减 天
 date("Y-m-d",strtotime("2013-11-12 12:12:12 +1 year"))  ;
原文地址:https://www.cnblogs.com/feimengv/p/4164695.html