This question already has an answer here:
How to find the time elapsed since a date time stamp like 2010-04-28 17:25:43
, final out put text should be like xx Minutes Ago
/xx Days Ago
This question already has an answer here:
How to find the time elapsed since a date time stamp like 2010-04-28 17:25:43
, final out put text should be like xx Minutes Ago
/xx Days Ago
Want to share php function which results in grammatically correct Facebook like human readable time format.
Example:
Result:
less than 1 minute ago
I think I have a function which should do what you want:
Simply apply it to the difference between
time()
andstrtotime('2010-04-28 17:25:43')
as so:Use This one and you can get the
Refer this http://ca2.php.net/manual/en/dateinterval.format.php
Convert [saved_date] to timestamp. Get current timestamp.
current timestamp - [saved_date] timestamp.
Then you can format it with date();
You can normally convert most date formats to timestamps with the strtotime() function.
Improvisation to the function "humanTiming" by arnorhs. It would calculate a "fully stretched" translation of time string to human readable text version. For example to say it like "1 week 2 days 1 hour 28 minutes 14 seconds"
Here I am using custom function for finding the time elapsed since a date time.