timeago

Display “time ago” instead of datetime in PHP Codeigniter

偶尔善良 提交于 2019-12-29 08:15:14
问题 I would like to display a time format like twitter and FB (Posted 3 hours ago, Posted 2 minutes ago and so on...) I've tried this piece of code without success : function format_interval($timestamp, $granularity = 2) { $units = array('1 year|@count years' => 31536000, '1 week|@count weeks' => 604800, '1 day|@count days' => 86400, '1 hour|@count hours' => 3600, '1 min|@count min' => 60, '1 sec|@count sec' => 1); $output = ''; foreach ($units as $key => $value) { $key = explode('|', $key); if (

Timeago + Localtime combined

醉酒当歌 提交于 2019-12-23 10:00:09
问题 I'm trying to combine timeago with datejs ( with help of this to get format for local time ) for timeago I use the following: jQuery(document).ready(function() { jQuery("abbr.timeago").timeago(); }); For the localtime i use this: jQuery(document).ready(function() { $('.UTCTimestamp').localTimeFromUTC('MM/dd/yyyy hh:mm:ss'); }); How do I combine those two together? Right now I'm only able to use one at the time like this: For Timeago: <span class='UTCTimestamp'>2011-09-09 10:10:10</span> and

Activate timeago on newly added elements only

匆匆过客 提交于 2019-12-22 00:20:39
问题 I'm trying to fix the problem of not repeating the timeago function to elements that have it already, but adding it to the ones that don't have it. I'm trying this but newly added abbrs are not getting activated <abbr title="2011-09-15T12:46:26" class="timeago">less than a minute ago</abbr> function activate_timeago(){ setInterval(function(){ $('.timeago').each(function(){ if ($(this).data('active')!='yes'){ $(this).timeago(); $(this).data('active','yes'); } }); },60000); } any ideas? 回答1: i

Localizing timeAgoInWords in CakePHP

℡╲_俬逩灬. 提交于 2019-12-21 04:56:15
问题 In my CakePHP application, By using cake.bat i created POT files and by using PoEdit I created PO files. So by writing __('myword') i can see localized word in my application successfully. But now I need to localize "timeAgoInWords". When i run cake i18n extract , script didn't get the _dn() words in CakeTime http://api20.cakephp.org/view_source/cake-time#line-522 So i created a dummy.ctp file and copy-pasted contents from cake-time file to dummy file. I run cake script and POEdit again. And

jquery timeago NaN years ago with ISO date format

安稳与你 提交于 2019-12-13 07:40:23
问题 I have some issues with jQuery timeago plugin http://timeago.yarp.com/ First of all, the short call version doesn't works, I don't know why. $("#abbr.timeago").timeago(); displays nothing. I must use $("abbr.timeago").text($.timeago($(this).prop("title"))); Weird... (called in $(document).ready...) Anyway, timeago allways displays me a 'NaN years ago'. Here are some generated html tag with differents formats "yyyy-MM-dd'T'HH:mm:ss'Z'" <abbr class="timeago" title="2013-04-17T11:32:08Z">NaN

SQL query that displays “time ago dates” like “one week ago”, “two weeks ago”, “one month ago”, “one year ago”, etc

非 Y 不嫁゛ 提交于 2019-12-06 06:45:34
问题 I need a query that displays dates in the following format: Dates that fall in the past 7 days -> “one week ago” Dates that fall in the past 7 to 14 days -> “two week ago” Etc… Dates that fall in the past 30 days -> “one month ago” Dates that follow in the past 30 to 60 days -> “two months ago Etc.. Dates that fall in the past 365 days -> “one year ago” Dates that fall in the past 365 to 730 days -> “two years ago Etc... If you guys can point me to the right direction I’ll appreciate it.

How to get time difference between two timestamps in seconds with jQuery?

此生再无相见时 提交于 2019-11-29 01:37:55
I want to display x seconds ago based on a MySQL Timestamp. I found the plugin called timeago But I cannot find a way to make it display only seconds. I'm OK with 61 seconds, or 300 seconds. Any way to convert the output to seconds with timeago, or with pure jQuery / JavaScript ? Thanks for any help ! Edit: Sample Case : $time1 = "2014-02-02 23:54:04"; // plus PHP ways to format it. //$time2 = NOW() , or date(); whatever. I just want to get how many seconds since $time1 . Edit 2: Working code : <script type="text/javascript"> $(function(){ var d2 = new Date(); var d1 = new Date("2014-02-02 23

How to get time difference between two timestamps in seconds with jQuery?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 16:21:12
问题 I want to display x seconds ago based on a MySQL Timestamp. I found the plugin called timeago But I cannot find a way to make it display only seconds. I'm OK with 61 seconds, or 300 seconds. Any way to convert the output to seconds with timeago, or with pure jQuery / JavaScript ? Thanks for any help ! Edit: Sample Case : $time1 = "2014-02-02 23:54:04"; // plus PHP ways to format it. //$time2 = NOW() , or date(); whatever. I just want to get how many seconds since $time1 . Edit 2: Working code

Convert Unix timestamp to ISO 8601

南楼画角 提交于 2019-11-27 01:31:16
问题 I want to use the jquery timeago plugin - http://timeago.yarp.com/ I have timestamps like this 1331209044000 and the docs say i need an ISO 8601 timestamp. To be honest i have never heard of ISO 8601. How can i convert it? Cheers 回答1: Assuming your timestamp is in milliseconds (or you can convert to milliseconds easily) then you can use the Date constructor and the date.toISOString() method. var s = new Date(1331209044000).toISOString(); s; // => "2012-03-08T12:17:24.000Z" If you target older