![](/img/trans.png)
[英]How to calulate the difference between a MySQL timestamp and the current time in PHP
[英]Time difference between current time and timestamp+milliseconds
我想在php頁面上顯示當前服務器時間與日期時間行以及其中包含毫秒的行之間的差異,因此我想方程式看起來像((Datetime + Milliseconds)-Server Time) 。
唯一的問題是,我不確定如何在代碼中執行此操作。 我現在可以通過echo strtotime($row['date_added']) - time();
來獲取datetime行和當前時間之間的差異echo strtotime($row['date_added']) - time();
當我嘗試添加包含毫秒的行date_mil
,我得到了一個很長的數字。
在該行的日期date_added
看起來像2012-05-25 16:55:06
和價值date_mil
大約是218238
。
我仍在學習如何做所有這一切,這讓我感到困惑。 謝謝您的幫助!
我只是解決了自己的問題。
$difference = time() - strtotime($row['date_added']);
$milliseconds = round(($row['date_mil']) * .001);
echo $milliseconds - $difference;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.