<?php //PHP計算兩個時間差的方法 $startdate="2017-12-3 12:00:00"; $enddate="2017-12-4 12:00:00"; $date=floor((strtotime($enddate)-strtotime($startdate))/86400); $hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600); $minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60); $second=floor((strtotime($enddate)-strtotime($startdate))%86400%60); echo $date."天"; echo $hour."小時"; echo $minute."分鍾"; echo $second."秒; ?>
只是一點點的算法問題