开发者

Storing and retrieving a date in PHP?

开发者 https://www.devze.com 2023-01-06 20:14 出处:网络
This is what I need to do: I need to perform a PHP operation, then retrieve how long ago the last time the operation was performed was. I have it all figured out, except one thing - how do I find the

This is what I need to do: I need to perform a PHP operation, then retrieve how long ago the last time the operation was performed was. I have it all figured out, except one thing - how do I find the difference between two date/times? Or, is there an easier way to do this? (This is b开发者_开发问答ased in Wordpress, so I'm using wp_options to store the date/time data.)


If you just need it in seconds, convert both to seconds (use the strtotime() PHP function), then subtract one from the other.


If you're using PHP 5.3, take a look at DateTime::diff.

0

精彩评论

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