2017-03-16 52 views
1

我試圖讓TIMEAGO插件工作具有以下時間戳jQuery的TIMEAGO插件與unix時間戳工作

2017年3月16日18:37:20

然後我試圖將其轉換這個timestamp.but其仍然沒有工作

下面是代碼

<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> 

而且因爲我試圖做到這一點在表中。這裏是負責代碼

<td> 
        <?php 
    $datetime = $row['date']; 
    $datetime = strtotime($datetime); 
?> 
You opened this page <span class='demo_class' ><?php echo $datetime ; ?></span> 
</td> 

如果可能的話u能幫助我使代碼autoupdating?如時間,而無需刷新

自動改變TIMEAGO使用類似於這種

2008-07-17T09:24:17Z

jQuery的TIMEAGO的
+0

您如何告訴我們timeago期待的格式?我們不會去閱讀它的文檔 – nogad

+0

更新了這個問題。 –

+0

您可以使用php'date()'或mysql'DATE_FORMAT()'格式化日期' – nogad

回答

0

筆者在這裏。

As the docs reference,需要ISO 8601時間戳一切按預期在TIMEAGO:

<time class="timeago" datetime="2008-07-17T09:24:17Z">July 17, 2008</time> 

在PHP中,你需要這樣的片段,以輸出ISO 8601格式:

$time->format(DateTime::ISO8601);