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:
1289735677
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:
http://www.phpro.org/examples/Convert-Seconds-To-Hours-Minutes-Seconds-Words.html
http://www.laughing-buddha.net/php/lib/sec2hms/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With