修复传值为null和字符串整数时报错问题

Signed-off-by: 小和 <496631085@qq.com>
pull/443/head
小和 2023-05-23 06:24:21 +00:00 committed by Gitee
parent 1afdacbcd9
commit e90d619d5b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 5 additions and 5 deletions

View File

@ -164,11 +164,11 @@ class Date
*/
public static function unixtime($type = 'day', $offset = 0, $position = 'begin', $year = null, $month = null, $day = null, $hour = null, $minute = null)
{
$year = is_null($year) ? date('Y') : $year;
$month = is_null($month) ? date('m') : $month;
$day = is_null($day) ? date('d') : $day;
$hour = is_null($hour) ? date('H') : $hour;
$minute = is_null($minute) ? date('i') : $minute;
$year = is_null($year) ? (int)date('Y') : (int)$year;
$month = is_null($month) ? (int)date('m') : (int)$month;
$day = is_null($day) ? (int)date('d') : (int)$day;
$hour = is_null($hour) ? (int)date('H') : (int)$hour;
$minute = is_null($minute) ? (int)date('i') : (int)$minute;
$position = in_array($position, array('begin', 'start', 'first', 'front'));
$baseTime = mktime(0, 0, 0, $month, $day, $year);