Function to return amount of time between two unix time stamps as it would be verbalized.

/ Published in: PHP
Save to your folder(s)

Display amount of time distance between two timestamps in the 2 largest possible time frame terms, adding plural when appropriate. If the second parameter for ending time stamp is left blank the current time() is used.

usage: `echo timeSince(1300000006,1300162842); // will echo 1 day, 21 hours` and `echo timeSince(1300162702,1300162842); // will echo 2 minutes, 20 seconds`

The last parameter is the number of time units to display (ie: 2 might display minutes, seconds while 3 will display hours, minutes seconds). This defaults to 2.

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.