Sometimes when you are building a website or an mobile application, you need to display date and time in a user friendly way. Showing relative time is a good option. Social networking sites like Facebook and Twitter use a simple function which enables them to show relative time. This can be used for comments and other from of communication to tell the time ago instead of the exact time which might not be correct to some one in another time zone. Here’s how it can be done in C#.
Refer to this post if you want to do it using PHP.
http://www.maskaravivek.com/blog/c/time-ago-function/