$dday = mktime(13, 00,00, 02, 07, 2013);
$today = mktime(12,30,00, 02, 08, 2018);
$difference = $today - $dday;
$DateCalculation = floor($difference / 84600);
echo $DateCalculation;
这一天是1.但实际上它不是1.当时间是13.00时,这一天将是1。任何人都可以回答我吗?
答案 0 :(得分:2)
DateTime类使日期和时间的处理变得更加容易mktime()
$datetime1 = new DateTime('2013-02-07 13:00:00');
$datetime2 = new DateTime('2013-02-08 12:30:00');
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%a days %h hours');
echo $elapsed . PHP_EOL;
echo "Days: " . $interval->format('%a') . PHP_EOL;
// Output
0 days 23 hours
Days: 0
答案 1 :(得分:0)
$dday = ('13, 00,00, 02, 07, 2013');
$sub = substr($dday, 14,-6);
$today = ('12,30,00, 02, 08, 2018');
$sub_today = substr($today, 14,-6);
$difference = $sub_today - $sub ;
echo $difference .' day'; // -- will output: 1 day