The event returns a standardized timestamp in the format of ‘Sat Oct 25 21:55:29 +0000 2008’ How can I compare this with the current time in PHP so that it gives me the result in a form like ‘It has been 15 minutes!’ or ‘It has been three days!’ Also, how can I get the current time?
Share
First convert that string to a UNIX timestamp using strtotime():
Then to get the current UNIX timestamp use time():
Then get the number of seconds between those timestamps:
And finally use division to convert the number of seconds into number of days or hours or whatever:
For more information on calculating relative time, see How do I calculate relative time?.