将时间戳转换为相对日期/时间(例如,“2分钟前”)并使用Javascript连续更新它 [英] Converting a timestamp to a relative date/time (e.g., "2 minutes ago") and continuously updating it with Javascript

查看:105
本文介绍了将时间戳转换为相对日期/时间(例如,“2分钟前”)并使用Javascript连续更新它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道Facebook是怎么做到的时间前。我正在尝试用PHP / Javascript做同样的事情

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

我认为它有点像PHP在HTML中呈现时间戳,然后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?

格式化为2分钟前的时间戳的示例。 http://i39.tinypic.com/1yk7eq.gif

推荐答案

http://timeago.yarp.com/

http://timeago.yarp.com/

这是一个很棒的 jQuery 插件,它非常简洁地解释了这个概念。

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

这篇关于将时间戳转换为相对日期/时间(例如,“2分钟前”)并使用Javascript连续更新它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆