How would I check if a date in the format "2008-02-16 12:59:57" is less than 24 hours ago?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Php has a comparison function between two date/time objects, but I don't really like it very much. It can be imprecise.
What I do is use strtotime() to make a unix timestamp out of the date object, then compare it with the output of time().
Just adding another answer, using
strtotime
's relative dates:I think this makes the code much more readable.
There should be you variable date Like
You can Compare both date after convert date into time-stamp so :
OR
Maybe it will be more easy to understand...