return difference of two dates in PHP
I need to compare a past/future date with current date in PHP and present
the difference in a "4 hours until", or "2 days 3 hours until" or "5 hours
ago" format. Optionally in a "-4h" (which is bad) or "4h" (which is good)
format.
So in a example:
x = $expiry_date - $todays_date
If the result is positive, eg. $expiry_date is 4 hours in the future, x =
"4 hours to go", or "4 hrs". If the result was negative, for example "4
hours ago" or "-4hrs".
Any other, similarly sounding result formats are fine.
Any help please?
No comments:
Post a Comment