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.
精彩评论