我的网站出现持续的 mktime 错误。
functions.php 中的主要 mktime 代码如下:
function mkprettytime($s) {
if ($s < 0)
$s = 0;
$t = array();
$t["day"] = floor($s / 86400);
$s -= $t["day"] * 86400;
$t["hour"] = floor($s / 3600);
$s -= $t["hour"] * 3600;
$t["min"] = floor($s / 60);
$s -= $t["min"] * 60;
$t["sec"] = $s;
if ($t["day"])
return $t["day"] . "d " . sprintf("%02d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]);
if ($t["hour"])
return sprintf("%d:%02d:%02d", $t["hour"], $t["min"], $t["sec"]);
return sprintf("%d:%02d", $t["min"], $t["sec"]);
}
function sql_timestamp_to_unix_timestamp($s){
return mktime(substr($s, 11, 2), substr($s, 14, 2), substr($s, 17, 2), substr($s, 5, 2), substr($s, 8, 2), substr($s, 0, 4));
}
错误是:
[12-Feb-2013 11:06:36] PHP Warning: mktime() expects parameter 4 to be long, string given in /home/myweb/public_html/bgcode/functions.php on line 543
而 543 行是(来自上面的行/脚本)
return mktime(substr($s, 11, 2), substr($s, 14, 2), substr($s, 17, 2), substr($s, 5, 2), substr($s, 8, 2), substr($s, 0, 4));