теперь дошло
вот, пожалуйста)
function time(){
return 3601;
}
function date(k,l){var d,a,h="Sun Mon Tues Wednes Thurs Fri Satur January February March April May June July August September October November December".split(" "),f=/\\?(.?)/gi,g=function(b,c){return a[b]?a[b]():c},e=function(b,a){for(b=String(b);b.length<a;)b="0"+b;return b};a={d:function(){return e(a.j(),2)},D:function(){return a.l().slice(0,3)},j:function(){return d.getDate()},l:function(){return h[a.w()]+"day"},N:function(){return a.w()||7},S:function(){var b=a.j(),c=b%10;3>=c&&1==parseInt(b%
100/10,10)&&(c=0);return["st","nd","rd"][c-1]||"th"},w:function(){return d.getDay()},z:function(){var b=new Date(a.Y(),a.n()-1,a.j()),c=new Date(a.Y(),0,1);return Math.round((b-c)/864E5)},W:function(){var b=new Date(a.Y(),a.n()-1,a.j()-a.N()+3),c=new Date(b.getFullYear(),0,4);return e(1+Math.round((b-c)/864E5/7),2)},F:function(){return h[6+a.n()]},m:function(){return e(a.n(),2)},M:function(){return a.F().slice(0,3)},n:function(){return d.getMonth()+1},t:function(){return(new Date(a.Y(),a.n(),0)).getDate()},
L:function(){var b=a.Y();return 0===b%4&0!==b%100|0===b%400},o:function(){var b=a.n(),c=a.W();return a.Y()+(12===b&&9>c?1:1===b&&9<c?-1:0)},Y:function(){return d.getFullYear()},y:function(){return a.Y().toString().slice(-2)},a:function(){return 11<d.getHours()?"pm":"am"},A:function(){return a.a().toUpperCase()},B:function(){var a=3600*d.getUTCHours(),c=60*d.getUTCMinutes(),f=d.getUTCSeconds();return e(Math.floor((a+c+f+3600)/86.4)%1E3,3)},g:function(){return a.G()%12||12},G:function(){return d.getHours()},
h:function(){return e(a.g(),2)},H:function(){return e(a.G(),2)},i:function(){return e(d.getMinutes(),2)},s:function(){return e(d.getSeconds(),2)},u:function(){return e(1E3*d.getMilliseconds(),6)},e:function(){throw"Not supported (see source code of date() for timezone on how to add support)";},I:function(){var b=new Date(a.Y(),0),c=Date.UTC(a.Y(),0),d=new Date(a.Y(),6),e=Date.UTC(a.Y(),6);return b-c!==d-e?1:0},O:function(){var a=d.getTimezoneOffset(),c=Math.abs(a);return(0<a?"-":"+")+e(100*Math.floor(c/
60)+c%60,4)},P:function(){var b=a.O();return b.substr(0,3)+":"+b.substr(3,2)},T:function(){return"UTC"},Z:function(){return 60*-d.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(f,g)},r:function(){return"D, d M Y H:i:s O".replace(f,g)},U:function(){return d/1E3|0}};this.date=function(a,c){d=void 0===c?new Date:c instanceof Date?new Date(c):new Date(1E3*c);return a.replace(f,g)};return this.date(k,l)};
function ago(time) {
var df = time() - time;
if (df <= 19) {
return 'Elə indi';
}
else if (df > 19 && df <= 59) {
return 'Bir neçə saniyə əvvəl';
}
var mas = [
[ 31556926, ['ay', 2628000] ],
[ 2629744, ['həftə', 604800] ],
[ 604800, ['gün', 86400] ],
[ 86400, ['saat', 3600] ],
[ 3600, ['dəqiqə', 60] ],
[ 60, ['saniyə', 1] ]
];
var intg = [];
for ( var i = 0, len = mas.length; i < len; i++ ) {
var el = mas[i][1];
if ( df < mas[i][0]) {
intg[1] = el;
} else {
intg[0] = el;
}
}
var value = Math.floor(df/intg[1][1]);
var ago = value + ' ' + intg[1][0];
var days = new Array ('Bazar', 'Bazar ertəsi', 'Çərşənbə axşamı', 'Çərşənbə', 'Cümə axşamı', 'Cümə', 'Şənbə');
var day = days[date('w', time)];
var months = new Array ('', 'Yanvar', 'Fevral', 'Mart', 'Aprel', 'May', 'İyun', 'İyul', 'Avqust', 'Sentyabr', 'Oktyabr', 'Noyabr', 'Dekabr');
var month = months[date('m', time)];
if (ago == '1 gün') {
return 'Dünən ' + date('H:i', time);
}
else if ((value == 2 || value == 3 || value == 4 || value == 5 || value == 6 || value == 7) && intg[1][0] == 'gün') {
return day + ' günü ' + date('H:i', time);
}
else if (value <= 59 && intg[1][0] == 'dəqiqə' || intg[1][0] == 'saat') {
return ago + ' əvvəl';
}
else {
return date('d', time) + ' ' + month + ' ' + date('Y H:i', time);
}
}
// == ОТЛАДКА ==
var t = time();
alert(ago(t));