0
誰能幫我弄小時,分鐘,這段代碼秒:解析時間
<strong class="countdown"> 23:16:27</strong>
我有這個代碼試圖讓數據:
$r = sscanf($str, "%f,%f,%f", $hour, $minutes, $secundes);
如何解析這個倒計時器與正則表達式或其他東西,並投入$小時,$分鐘,$秒? (對不起,我的英文)
誰能幫我弄小時,分鐘,這段代碼秒:解析時間
<strong class="countdown"> 23:16:27</strong>
我有這個代碼試圖讓數據:
$r = sscanf($str, "%f,%f,%f", $hour, $minutes, $secundes);
如何解析這個倒計時器與正則表達式或其他東西,並投入$小時,$分鐘,$秒? (對不起,我的英文)
if (preg_match('/[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}/i', $str, $m)) {
$hours = $m[1];
$minutes = $m[2];
$seconds = $m[3];
}
使用strtotime();請參閱here:
<?php
$time = '23:16:27';
$time = strtotime($time);
$hour = date('g',$time);
$minute = date('i',$time);
$second = date('s',$time);
echo "hour: " . $hour . "<br>";
echo "minute: " . $minute . "<br>";
echo "second: " . $second . "<br>";
?>
$ r = sscanf($ str,「%f,%f,%f」,$ hour,$ minutes,$ secundes); – asdasdasd
strtotime()不適用於此? – bozdoz
$ str = $ xpath2-> query(「// strong [@ class ='countdown']」 - > item(0) - > textContent); – asdasdasd