Time Ago or Time To Go function in php

This tutorial shows how to display how much time already passed or how much time to go for a given datetime.

We have to implement this kind of functionality in many scenarios like someone has posted comment on your blog, tutorial, product or article then you want to show how much time ago that particular comment was posted. The time ago function may display the time format like – 1 sec ago, 2 secs ago, 1 min ago, 3 mins ago or 4 days ago etc.

Now we may need to display also how many seconds, minutes or even days “to go” to happen something. In real life scenarios like Pepsi IPL 15 days to go, Brasil Football World Cup 5 days to go etc. Continue reading “Time Ago or Time To Go function in php”