时间过去 +当地时间合并
我正在尝试将 timeago
与 结合起来datejs (在此帮助下获取
timeago
的当地时间格式)
我使用以下内容:
jQuery(document).ready(function() {
jQuery("abbr.timeago").timeago();
});
对于localtime
我使用这个:
jQuery(document).ready(function() {
$('.UTCTimestamp').localTimeFromUTC('MM/dd/yyyy hh:mm:ss');
});
我如何将这两者结合在一起?现在我只能一次使用一个,如下所示:
For Timeago:
<span class='UTCTimestamp'>2011-09-09 10:10:10</span>
和 for localtime;
<abbr class='timeago' title='2011-09-09 10:10:10'>2011-09-09 10:10:10</abbr>
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 for localtime;
<abbr class='timeago' title='2011-09-09 10:10:10'>2011-09-09 10:10:10</abbr>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除此之外,不要添加任何 javascript 代码或 jquery 代码;
然后添加“Z”(或包括 T)。有关更多信息,请访问此链接
http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
don't add any javascript code or jquery code except this;
and then add 'Z' (or including T). for more information go to this link
http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
我正在尝试做同样的事情 - 这就是我最终想通的。
我的 HTML 有这样的:
然后我有这 2 个 javascript 块:
这是在 HTML 中使用 ASP.NET MVC Razor 语法,但基本上它的作用是获取两种不同格式的日期/时间字符串。所有时间均以 UTC 格式存储。 timeago 插件使用 ISO 8601 格式的字符串来发挥其魔力,而 localtime '插件' 使用 RCF1123 格式。
ISO8601 看起来像这样: yyyy-MM-dd HH:mm:ssZ
RFC1123 看起来像这样: ddd, dd MMM yyyy HH:mm:ss GMT
最终结果是在屏幕上我看到 timeago 的“大约 10 分钟前”,但是当我悬停时,我得到“10/26/2011 08:57:43 PM”。
I am trying to do the same thing - here is what I finally figured out.
My HTML has this:
I then have these 2 chunks of javascript:
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".