PHP计算当前时间之后(之前)的时间

PHP中有一个非常厉害的函数,strtotime()函数,这个函数有一个异常厉害的使用方法,手册上说的有,但是估计在实际应用中能够想到的人不多:

请看下面的列子:
当前时间之后的时间是“+”,之前的时间当然用“-”就可以了!

strtotime(”+1 week”)     当前时间一周之后

strtotime(”-1 week”)     当前时间一周之前

strtotime(”+1 months”)   一个月之后

strtotime(”+5 days”)     5天之后

strtotime(”+12 hours”)   12个小时之后

strtotime(”+20 minutes”) 20分钟之后

strtotime(”+30 seconds”) 30秒之后

strtotime(”Last  Saturday“) 上周六的时间

strtotime(”Next Saturday”) 下周六

date('Y-m-d' , strtotime('next monday' , strtotime('2015-05-04')));

2015-05-04 的下个周一

date(”Y-m-d H:i:s”,strtotime(”+1 months +1 week +3 days +4 hours +16 minutes +32 seconds”));

当前时间一个月零两周,零三天,零4个小时16分钟32秒后的时间


猜你喜欢

转载自happymc.iteye.com/blog/2208651