Yii 1.1: timeago2

this is create from yii extension time ago, read now time from server

this extension is created from time ago but different with time ago is : in time ago if client computer time was not set true this extension return false time, for example if you send the time of now to time ago and client time be in the future year it shows: one year ago

in this extension you should send server now time to time ago plugin (it changed by me.) it calculate the difference of time between the server and client, and every time it gets now time minus difference and always whatever client computer has been true,in future or past, it will respond for above example: less than a minute ago.


tested on yii 1.15 ; may works well with previous version .


download it , and extract it to protected/extensions dir , then in your view file use it as other standard CWidget class .

this widget just replace the text of specified element (abbr or time tag of html5); "you should send now time from server like in this version like down in your view file. and replace the strings in your language"

        $this->widget('ext.timeago.JTimeAgo', array(
            'selector' => '.timeago',
                'now'=>time()*1000, // this should *1000 becous in js need milisecond
                    prefixAgo: null,
                    prefixFromNow: null,
                    suffixAgo: "پیش",
                    suffixFromNow: "از حال",
                    seconds: "کمتر از یک دقیقه",
                    minute: "حدود یک دقیقه",
                    minutes: "%d دقیقه",
                    hour: "حدود یک ساعت",
                    hours: "حدود %d ساعت",
                    day: "یک روز",
                    days: "%d روز",
                    month: "حدود یک ماه",
                    months: "%d ماه",
                    year: "حدود یک سال",
                    years: "%d سال",
                    wordSeparator: " "
        <div class="timeago" title="<?php echo  date(DATE_ISO8601,time());  ?>">this text will be title</div>

create by hooman mirghasemi

هومن میرقاسمی

Total 1 comment

#19806 report it
Achmad Hadi Kurnia at 2016/03/16 07:02am

Demo please

Leave a comment

Please to leave your comment.

Create extension