开发者

Timeago + Localtime combined

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() {
    $('.UTCT开发者_JS百科imestamp').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 for localtime;

<abbr class='timeago' title='2011-09-09 10:10:10'>2011-09-09 10:10:10</abbr>


don't add any javascript code or jquery code except this;

$('.timeago').timeago();

and then add 'Z' (or including T). for more information go to this link

<abbr class='timeago' title='2011-09-09 10:10:10Z'></abbr>

http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations


I am trying to do the same thing - here is what I finally figured out.

My HTML has this:

<abbr class="timeago localtime" title="@Model.GetLastUpdatedDateTimeISO8601(category, report)">@Model.GetLastUpdatedDateTimeRFC1123(category,report)</abbr><br />

I then have these 2 chunks of javascript:

 $('.localtime').localTimeFromUTC('MM/dd/yyyy hh:mm:ss a');

 $('.timeago').timeago();

This is using ASP.NET MVC Razor syntax in the HTML, but basically what that does is get the date/time strings in two different formats. All times are stored in UTC. The timeago plugin uses the ISO 8601 formatted string to do its magic, and the localtime 'plugin' uses the RCF1123 format.

ISO8601 looks like this: yyyy-MM-dd HH:mm:ssZ

RFC1123 looks like this: ddd, dd MMM yyyy HH:mm:ss GMT

The final result is that on-screen I see timeago's "about 10 minutes ago", but when I hover I get "10/26/2011 08:57:43 PM".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜