[英]Jquery Timeago plugin to work with unix timestamp
I am trying to make timeago plugin work with the following timestamps 我正在尝试使用以下时间戳使timeago插件工作
2017-03-16 18:37:20
2017-03-16 18:37:20
then i tried converting it to this timestamp.but its still not working 然后我尝试将其转换为此时间戳。但它仍然无法正常工作
1489685840
1489685840
Here is the code 这是代码
<script src="jquery.timeago.js" type="text/javascript"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.livequery.min" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".demo_class").timeago();
});
</script>
And since i am trying to do this in a table .here is the responsible code 因为我试图在表中执行此操作。负责的代码
<td>
<?php
$datetime = $row['date'];
$datetime = strtotime($datetime);
?>
You opened this page <span class='demo_class' ><?php echo $datetime ; ?></span>
</td>
If possible can u help me make the code autoupdating? 如果可能,你可以帮助我使代码自动更新吗? like the time will change automatically without refreshing
喜欢时间会自动改变而不刷新
Timeago uses something like this Timeago使用这样的东西
2008-07-17T09:24:17Z
2008-07-17T09:24:17Z
Author of jquery-timeago here. jquery-timeago的作者在这里。
As the docs reference , an ISO 8601 timestamp is required for everything to work as expected in timeago: 正如文档所引用的那样,在timeago中按预期工作的所有内容都需要ISO 8601时间戳:
<time class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</time>
In PHP, you'll need a snippet like this to output ISO 8601 format: 在PHP中,您需要这样的代码段来输出ISO 8601格式:
$time->format(DateTime::ISO8601);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.