我想从第一句话和第二句话[括号内]获取时间,如下所示,结果一分钟即可看到差异。例如,在这种情况下,结果将是1分钟。
[04:38:41] Preflight started, flying offline
[04:39:29] Pushing back with 7512 kg of fuel
如果您能帮助我找出如何用PHP做到这一点,我表示感谢。
谢谢
答案 0 :(得分:1)
您可以使用以下示例获取两者之间的秒数:
$datetime1 = strtotime('11:01:00');
$datetime2 = strtotime('11:00:01');
echo abs($datetime1-$datetime2);
答案 1 :(得分:0)
您可以使用以下示例以秒为单位获取差异。
$string1 = '[04:38:41] Preflight started, flying offline';
$string2 = '[04:39:29] Pushing back with 7512 kg of fuel';
$datetime1 = substr($string1,4,6); // Getting the time of the first string
$datetime2 = substr($string2,4,6); // Getting the time of the second string
echo abs($datetime1-$datetime2); // Calculating the difference between the two values.
答案 2 :(得分:0)
尝试
<?php
$time1 = explode(':', "04:38:41");
$time2 = explode(':', "04:39:29");
echo $result = $time2[1] - $time1[1];
?>
或者,您可以阅读全文
<?php
$time1_string = "[04:38:41] Preflight started, flying offline";
$time2_string = "[04:39:29] Pushing back with 7512 kg of fuel";
$time1 = explode(':', $time1_string);
$time2 = explode(':', $time2_string);
echo $result = $time2[1] - $time1[1];
?>
答案 3 :(得分:0)
您也可以使用preg_match()
示例:
from PIL import Image
im = Image.open("Picture2.png")
rgb_im = im.convert('RGB')
rgb_im.save('Picture2.jpg')