2 * extraceted from http://ejohn.org/files/pretty.js
3 * JavaScript Pretty Date
4 * Copyright (c) 2008 John Resig (jquery.com)
5 * Licensed under the MIT license.
8 function date_pretty(date) {
10 diff = (((new Date()).getTime() - date.getTime()) / 1000),
11 day_diff = Math.floor(diff / 86400);
13 if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
16 return day_diff == 0 && (
17 diff < 60 && "just now" ||
18 diff < 120 && "1 minute ago" ||
19 diff < 3600 && Math.floor( diff / 60 ) + " minutes ago" ||
20 diff < 7200 && "1 hour ago" ||
21 diff < 86400 && Math.floor( diff / 3600 ) + " hours ago") ||
22 day_diff == 1 && "Yesterday" ||
23 day_diff < 7 && day_diff + " days ago" ||
24 day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks ago";