2013-07-12 62 views
0

於是,我就一個時間字符串爲「X秒前」和stucked轉換這個問題:PHP改變時間戳格式

while($row = mysql_fetch_array($result)) 
<a href="#Profile"><class="profilep" id="postp" /></a> 
<ul> 
<li class="userName"></li> 
<li class="distance"></li> 
</ul> 
<div class="time"> 
'. 
$eventTime = $row['time']; 
$age = time() - strtotime($eventTime); 
echo $age "ago" 
.' 
</div></div> 
<p align="justify"></p> 
</div> 
</article>'; 

循環載荷不僅$年齡,但也$行[「時間」 ]。我想知道爲什麼會發生,以及如何解決它?感謝您的時間和幫助我學習。

+0

剛剛刪除''''讓代碼格式化爲代碼塊。 –

回答

0

連接似乎都是錯誤的。先進行計算,然後創建輸出。下次請包含正確的代碼。

while($row = mysql_fetch_array($result)) { 
    $eventTime = $row['time']; 
    $age = time() - strtotime($eventTime); 
    // Here is probably something missing. 
    echo ' 
       <a href="#Profile"><[what tag should go here?] class="profilep" id="postp" /></a> 
       <ul> 
        <li class="userName"></li> 
        <li class="distance"></li> 
       </ul> 
       <div class="time">' . $age . ' seconds ago</div> 
      </div> 
      <p align="justify"></p> 
     </div> 
    </article>'; 
} 
+0

感謝您的建議。我還在學習。所以每個答案對我都很有價值。 –