jquery - how to get difference between two dates using javascript -
this question has answer here:
i calculating number of days between 'from' , 'to' date. example, if date mm/dd/yyyy , date mm/dd/yyyy. how result using javascript?
from date like:11/25/2014 date :11/27/2014
i need result 2 using javascript>
the implementation john resig:
// date difference. // @see http://ejohn.org/projects/javascript-pretty-date/ function prettydate(date, now){ var diff = (((now || (new date())).gettime() - date.gettime()) / 1000), day_diff = math.floor(diff / 86400); if (isnan(day_diff) || day_diff < 0 || day_diff >= 31) return this.format(date, 'yyyy-mm-dd'); return day_diff == 0 && ( diff < 60 && "just now" || diff < 120 && "1 minute ago" || diff < 3600 && math.floor( diff / 60 ) + " minutes ago" || diff < 7200 && "1 hour ago" || diff < 86400 && math.floor( diff / 3600 ) + " hours ago") || day_diff == 1 && "yesterday" || day_diff < 7 && day_diff + " days ago" || day_diff < 31 && math.ceil( day_diff / 7 ) + " weeks ago"; },
Comments
Post a Comment