警告:strtotime()期望参数1为字符串

时间:2012-08-17 21:08:50

标签: php arrays strtotime

您好我发现此错误:警告:strtotime()期望参数1为字符串

当我尝试这样做时:

$holidays = array("2008-12-25","2008-12-26","2009-01-01");
$today = date('Y-m-d');
$ticketDate = date('Y-m-d',strtotime($this->getCreateDate()));
$dayCount = $this->getWorkingDays($ticketDate,$today,$holidays);
$dayToHour = $dayCount * 24;
$horas=$cfg->getGracePeriod();
print_r ($holidays);

我明白了:Array ( [0] => 2008-12-25 [1] => 2008-12-26 [2] => 2009-01-01 ) 但当我替换

$holidays = array("2008-12-25","2008-12-26","2009-01-01");

用这个:

$holidays = array($cfg->holydays());

我明白了:

Warning: strtotime() expects parameter 1 to be string, array given in file.php on line 262
Array ( [0] => Array ( [0] => 2012-08-21 [1] => 2012-08-20 [2] => 2012-08-10 ) )

你能帮帮我吗?

1 个答案:

答案 0 :(得分:4)

您将数组包装在数组中。看起来$cfg->holydays()已经返回一个数组,所以很简单

$holidays = $cfg->holydays()

会做的伎俩