Home » Php » php – Converting a timestamp to a relative date/time (e.g., "2 minutes ago") and continuously updating it with Javascript

php – Converting a timestamp to a relative date/time (e.g., "2 minutes ago") and continuously updating it with Javascript

Posted by: admin July 12, 2020 Leave a comment

Questions:

Does anybody know how did Facebook do that "time ago". I’m trying to do the same with PHP/Javascript

I think it works something like PHP renders timestamp in HTML and then Javascript continuously calculate the time ago; does anybody know any more info about this?

Example of a timestamp formatted as "2 minutes ago"

How to&Answers:

http://timeago.yarp.com/

This is a great jQuery plugin for it, and it explains the concept quite concisely.

Answer:

Here’s another fully-customizable alternative:
https://github.com/layam/js_humanized_time_span