Storing and retrieving a date in PHP?
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.
精彩评论