getTimestamp : function(time)
{
//--------------------------------------------------------------
// http://af-design.com/blog/2009/02/10/twitter-like-timestamps/
//--------------------------------------------------------------
var system_date = new Date(time);
var user_date = new Date();
var diff = Math.floor((user_date - system_date) / 1000);
if (diff <= 1) return "just now";
if (diff < 20) return diff + " seconds ago";
if (diff < 40) return "half a minute ago";
if (diff < 60) return "less than a minute ago";
if (diff <= 90) return "one minute ago";
if (diff <= 3540) return Math.round(diff / 60) + " minutes ago";
if (diff <= 5400) return "1 hour ago";
if (diff <= 86400) return Math.round(diff / 3600) + " hours ago";
if (diff <= 129600) return "1 day ago";
if (diff < 604800) return Math.round(diff / 86400) + " days ago";
if (diff <= 777600) return "1 week ago";
return "on " + time;
},
Hope it helps
m
On 31 March 2011 18:42, Burhan Tanweer <btanweer@gmail.com> wrote:
Hi,We would like to display twitter reasults on our search engine with the time in twiiter format like seconds ago, minutes ago etc.I know that a lot of you have worked on Twitter API. Does anyone has a function that can take created_at string from twitter search feed and convert into into seconds, minutes or days using Javascript?If you have done it, please send me the code. I will appreciate your help and looking forward to hear from developers team.ThanksBurhan Tanweer--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk
--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: http://groups.google.com/group/twitter-development-talk
No comments:
Post a Comment