![](/img/trans.png)
[英]Calculate the hours minutes and days of difference between two date and hours
[英]How to calculate Date Difference in hours and minutes using PHP?
我有這段代碼,他計算出日期差,到目前為止,它很好,但是我有問題,我想從較低的值中減去較高的數字,並在負數上顯示值,並且此代碼自動找到我不希望較高的數字。
$to_time = strtotime("2012-10-25 10:42:00");
$from_time = strtotime("2012-10-26 10:21:00");
echo round(abs($to_time - $from_time) / 60,2). " minute";
嘗試
echo round(($to_time - $from_time) / 60,2). " minute";
嘗試這個
$to_time = strtotime("2012-10-25 10:42:00");
$from_time = strtotime("2012-10-26 10:21:00");
echo round(($to_time - $from_time)/60,2). " minute";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.