Php 两次相减?

Php 两次相减?,php,Php,在大学里,我一直在问这个问题 用一次减去另一次。时间格式为“HH:MM:SS:FF”,其中: HH = hours – there are 24 hours in a day MM = minutes – there are 60 minutes in a hour SS = seconds – there are 60 seconds in a minute FF = frames – there are 25 frames in a second 时间总是11个字符长,每个元素总是2个字符

在大学里,我一直在问这个问题

用一次减去另一次。时间格式为“HH:MM:SS:FF”,其中:

HH = hours – there are 24 hours in a day
MM = minutes – there are 60 minutes in a hour
SS = seconds – there are 60 seconds in a minute
FF = frames – there are 25 frames in a second
时间总是11个字符长,每个元素总是2个字符-如果需要,用零填充

 subtract $y from $x

'$x = “03:14:59:20”;
 $y = “01:16:01:02”;
我已经完成了这个代码

<?php
$now = new DateTime(); // current date/time
$now = new DateTime("03:14:59:20");
$ref = new DateTime("01:16:01:02");
$diff = $now->diff($ref);
printf('%d hours, %d minutes %d seconds %d frames', $diff->h, $diff->i, $diff->s, $diff->f);

您不能在时间中包含帧——PHP的DateTime类不知道帧。我该如何解决这个问题?将时间转换为秒,乘以25,然后将帧添加到时间中。然后减去这个以得到帧的差异。仍然使用DateTime函数还是从头开始?你能告诉我怎么做吗?你可以用
分解
concat将前3个结果分别转换成
x和y字符串
,然后你就剩下了帧,减去它们,再将其转换为最终答案。实际上,如果
frames1-frames2<0
,这可能不起作用