Blog

How to: Create facebook or twitter style “x-time ago” date format in php

Normally date formats are like “ January 1 2010 10:40:25 GMT” , “01 Mar 2010” . etc . But here I tell you ‘how to show date like “1 minutes ago” , “2 days ago” , displayed in Facebook , Twitter etc..

In php time(); function returns a Unix Value of current date and time like 123454487 . We can convert Unix value to readable date format using date(); function.

Here is the simple php code for display date as Twitter or Facebook style .

If you have any feedback, bug reports please comment below. Happy coding :)