Gandalf StormCrow
Gandalf StormCrow

Reputation: 26212

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

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"

Upvotes: 7

Views: 2139

Answers (2)

Will Tomlins
Will Tomlins

Reputation: 1474

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

Upvotes: 0

brianreavis
brianreavis

Reputation: 11546

http://timeago.yarp.com/

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

Upvotes: 22

Related Questions