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.
Requirements ¶
tested on yii 1.15 ; may works well with previous version .
Usage ¶
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"
<?php
$this->widget('ext.timeago.JTimeAgo', array(
'selector' => '.timeago',
'settings'=>array(
'allowFuture'=>true,
'refreshMillis'=>60000,
'now'=>time()*1000, // this should *1000 becous in js need milisecond
'isServerTime'=>true,
'strings'=>'js:{
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
Demo
Demo please
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.