从PHP开始并保持这种格式减去PHP中的时间戳:00:00:00

I have 2 strings:

$time1 = '00:00:10';
$time2 = '00:00:04';

Using PHP, how can I subtract $time1 from $time2 so that I end up with:

$time3 = '00:00:06';

Yes you can, but first you need to convert those timestamps to int format to be able to subtract them.

$time1_timestamp = strtotime($time1);
$time2_timestamp = strtotime($time2);

$time3 = $time1_timestamp - $time2_timestamp;

And then convert it back into hh:mm:ss format:

$time3 = date('H:i:s', $time3);