开发者

strtotime("-5 hours") not working?

开发者 https://www.devze.com 2023-01-12 04:05 出处:网络
I thought strtotime() would convert a \"string\" into a timestamp. If I add on to the time, it works fine, but if I try to subtract, it doesn\'t. D开发者_运维知识库oes anyone know a workaround?

I thought strtotime() would convert a "string" into a timestamp. If I add on to the time, it works fine, but if I try to subtract, it doesn't. D开发者_运维知识库oes anyone know a workaround?

Thanks in advance.


It seems to work fine for me...

echo strtotime("-5 hours");

Result:

1282061972


I recommend reading Derick Rethans's excellent guide on Date and Time, http://derickrethans.nl/talks/time-zendcon9.pdf, explanatory slides start at slide 16.

He's the author of PHP's date and time functions and recommends that you use the DateTime classes if possible.

0

精彩评论

暂无评论...
验证码 换一张
取 消