sea_1987 sea_1987 - 10 months ago 46
PHP Question

Showing time elapsed with php

I am wanting to show the time elapsed since the time posted for a blog or similiar, I am using php and I am storing the time posted as a unix timestamp but I cannot for the live of me work out how to show the time since it was posted using the stored timestamp.


If for example your posted timestamp is:


You can also get the current timestamp by using time(), for example.

Then you can take your posted timestamp from the current one:

time() - 1289735677

In that way you will get the seconds elapsed. Now you can change them to human readable format for example.

See examples on how you can convert seconds to human readable format: