开发者

Jquery, get time difference in minutes

开发者 https://www.devze.com 2023-03-25 01:43 出处:网络
I have a web page with a list of records from a database. For each record there is a timestamp, what I want to do is using the timestamp in mys开发者_Go百科ql I would like to get the time difference i

I have a web page with a list of records from a database. For each record there is a timestamp, what I want to do is using the timestamp in mys开发者_Go百科ql I would like to get the time difference in minutes from that timestamp up to the current time. How could I do this via jquery so I can update it in real time instead of having to hit the database over and over again to calculate the time difference?


There are many jQuery plug-ins which provide this functionality. http://timeago.yarp.com/ is the one I'm the most familiar with.


You will need datajs, data/time library (http://code.google.com/p/datejs/) to calculate time span. Other than that, remaining work would be time mapping between mysql and javascript - maybe you can use epoch.

0

精彩评论

暂无评论...
验证码 换一张
取 消