我有一个PHP报告,使用一个日期变量从MySQL数据库返回结果。
我没有写报告,它使用mktime
,我最近搬到一个新的服务器与最新版本的php,我现在得到
这是日期变量的创建:
$start_date = mktime(0,0,0,$StartMonth,$StartDay,$StartYear);
$end_date = mktime(23,59,59,$EndMonth,$EndDay,$EndYear);
然后得到日期:
if ($HTTP_SERVER_VARS['REQUEST_METHOD'] == "POST") {
if ($prefix == "Start") {
$currYear = $StartYear;
$currMonth = $StartMonth;
$currDay = $StartDay;
}
elseif ($prefix == "End") {
$currYear = $EndYear;
$currMonth = $EndMonth;
$currDay = $EndDay;
}
}
else {
$arr = getdate(mktime());
$currYear = $arr["year"];
$currMonth = $arr["mon"];
// If the user hasn't chosen a date,
// set the beginning day at the first of the month
if ($prefix == "Start")
$currDay = 01;
else
$currDay = $arr["mday"];
}
当我现在运行报告时,我得到Strict Standards: mktime(): You should be using the time() function instead
我已将其更改为$arr = getdate(time());
,它摆脱了错误,但现在日期选择器不工作。
不带参数调用mktime()
与调用time()
相同。函数声明如下:
int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )
换句话说,不使用参数与使用当前日期相同,这就是time()
所做的。
$ php -a
Interactive shell
php > echo mktime();
Strict Standards: mktime(): You should be using the time() function instead in php shell code on line 1
1450208188
php > echo time();
1450208189
php >
没有任何问题,因为您将mktime()
更改为time()
。