我的php时区是Asia/Dhaka
(UTC + 6)
让我有两次时间
$a = 11:00:00;
$b = 09:00:00;
$sub = $a-$b; //it should return 02:00:00. But it adding the timezone and returns 08:00:00 (02:00:00 + 06:00:00)
如何避免从此输出中添加时区时间?
答案 0 :(得分:0)
尝试使用php DateTime
$a = '11:00:00';
$b = '09:00:00';
$start_date = new DateTime($a);
$since_start = $start_date->diff(new DateTime($b));
echo "{$since_start->h}:{$since_start->i}:{$since_start->s}";