jquery - how to compare timestamps -


i have looked on forum , found simmiliar posts converting timestamps jquery. havent found once fixes problem.

im working on webapplication, in combination jquery mobile. in webapp im showing twitter feeds: image , message. im trying date in there also.

wehn im retreiving date json this:

tue, 05 jun 2012 13:25:06 +0000 

now want compare date current date calculate time past. because want say: 1 second ago, 2 min ago 1 hour ago etc.

can tell me how can compare current date twitter date?

you can compare timestamp in javascript .

var input_date = new date('tue, 05 jun 2012 13:25:06 +0000').gettime(); var curr_date = new date().gettime(); if(input_date > curr_date){   alert("greater");     }else{   alert('small'); } 

here demo

​but per requirement, want show time '1 min ago','1 hour ago','2 days ago', can use jquery timeago plugin instead of doing javascrpt calculations. please see this plugin, it'll fulfill needs.


Comments