• 04-12-2021, 19:42:43
    #1
    Merhaba alttaki js koduyla tarihi x zaman önce, x yıl önce şeklinde ingilizce dilinde sorunsuz kullanabiliyorum ama blog dilini türkçeye çevirdiğimde kod bozuluyor hiç bir şekilde gösterim yapmıyor, hangi kısmı düzeltmem gerekli türkçe yapmak için, her türkçe dilindede, ingilizce dilindede tarih formatları aynı

    Örnek:

    Türkçe: 12/04/2021 07:06:00 ÖS - Çalışmıyor.
    İngilizce :12/04/2021 07:06:00 PM - Çalışıyor.

    Sorun sanırım son kısma eklenen ÖS kısmıyla alakalı ama kodda bu kısmı nasıl düzelteceğimi bulamadım, yardımcı olabilecek var mı?


    Kod:
    (function timeAgo(selector) {
        var templates = {
            prefix: "",
            suffix: "",
            seconds: "second ago",
            minute: "1 min",
            minutes: "%d min",
            hour: "1 hour",
            hours: "%d hour",
            day: "1 day",
            days: "%d days",
            month: "1 month",
            months: "%d month",
            year: "1 year",
            years: "%d years"
        };
        var template = function(t, n) {
            return templates[t] && templates[t].replace(/%d/i, Math.abs(Math.round(n)));
        };
        var timer = function(time) {
            if (!time) return;
            time = time.replace(/\.\d+/, "");
            time = time.replace(/-/, "/").replace(/-/, "/");
            time = time.replace(/T/, " ").replace(/Z/, " UTC");
            time = time.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2");
            time = new Date(time * 1000 || time);
            var now = new Date();
            var seconds = ((now.getTime() - time) * .001) >> 0;
            var minutes = seconds / 60;
            var hours = minutes / 60;
            var days = hours / 24;
            var years = days / 365;
            return templates.prefix + (seconds < 45 && template('seconds', seconds) || seconds < 90 && template('minute', 1) || minutes < 45 && template('minutes', minutes) || minutes < 90 && template('hour', 1) || hours < 24 && template('hours', hours) || hours < 42 && template('day', 1) || days < 30 && template('days', days) || days < 45 && template('month', 1) || days < 365 && template('months', days / 30) || years < 1.5 && template('year', 1) || template('years', years)) + templates.suffix;
        };
        var elements = document.getElementsByClassName('dtTm');
        for (var i in elements) {
            var $this = elements[i];
            if (typeof $this === 'object') {
                $this.innerHTML = timer($this.getAttribute('title') || $this.getAttribute('data-datetime'));
            }
        }
        setTimeout(timeAgo, 60000);
    })();
  • 05-12-2021, 19:23:12
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Hocam bu yazdığınız kod tam olarak ne işe yarıyor, siz ne yapmaya çalışıyorsunuz? Yanlış anlamayın da gözüme gereksiz uzun ve kötü gözüküyor.

    İstediğiniz sanırım bu
    // İngilizce GG/AA/YY
    new Date().toLocaleString("en-NZ")
    // Türkçe GG/AA/YY
    new Date().toLocaleString("en-NZ").replace(/pm/i,"ös").replace(/am/i,"öö")
  • 06-12-2021, 00:23:03
    #3
    Bu kod tarih biçimini x zaman önce olarak gösteriyor hocam, temanın içine yapımcı eklemiş ve türkçe dilinde çalışmıyor, verdiğiniz koduda denedim yine çalışmadı.

    Complexity adlı üyeden alıntı: mesajı görüntüle
    Hocam bu yazdığınız kod tam olarak ne işe yarıyor, siz ne yapmaya çalışıyorsunuz? Yanlış anlamayın da gözüme gereksiz uzun ve kötü gözüküyor.

    İstediğiniz sanırım bu
    // İngilizce GG/AA/YY
    new Date().toLocaleString("en-NZ")
    // Türkçe GG/AA/YY
    new Date().toLocaleString("en-NZ").replace(/pm/i,"ös").replace(/am/i,"öö")