標準功能:(見codepad)推薦使用:mktime():該is_dst參數已被棄用
<?php
$start_time_o = "18:00";
$end_time_o = date("H:i");
function get_time_difference(){
global $start_time_o, $end_time_o;
$start_time = explode(":", $start_time_o);
$end_time = explode(":", $end_time_o);
$start_time_stamp = mktime($start_time[0], $start_time[1], 0, 0, 0, 0);
$end_time_stamp = mktime($end_time[0], $end_time[1], 0, 0, 0, 0);
$time_difference = $end_time_stamp - $start_time_stamp;
return gmdate("H:i", $time_difference);
}
echo get_time_difference();
?>
修正函數:(見codepad)
<?php
$start_time_o = "18:00:01";
$end_time_o = date("H:i:s");
function get_time_difference(){
global $start_time_o, $end_time_o;
$start_time = explode(":", $start_time_o);
$end_time = explode(":", $end_time_o);
$start_time_stamp = mktime($start_time[0], $start_time[1], $start_time[2], 0, 0, 0, 0);
$end_time_stamp = mktime($end_time[0], $end_time[1], $end_time[2], 0, 0, 0, 0);
$time_difference = $end_time_stamp - $start_time_stamp;
return gmdate("H:i:s", $time_difference);
}
echo get_time_difference();
?>
第一功能沒有任何錯誤或通知。
修改函數給出了消息:
Deprecated: mktime(): The is_dst parameter is deprecated in C:\xampp\htdocs\index.php on line 13
Deprecated: mktime(): The is_dst parameter is deprecated in C:\xampp\htdocs\index.php on line 14
我不知道爲什麼,我只在修改函數接收消息? 這裏有什麼問題?
你是在'mktime()'函數上使用一個參數太多+1 –