我们不断收到上述错误。尝试在171以上添加$ start但结果相同。这是代码:
/**
* Get all of the months since a certain date
*/
public static function getMonthsSinceDate($start) {
$key_month = date('MY', $start); (note this is Line 171)
$key = 'months_since_' . $key_month;
$months = CodonCache::read($key);
if ($months === false) {
if (!is_numeric($start)) {
$start = strtotime($start);
}
$end = date('Ym');
do {
# Get the months
$month = date('M Y', $start);
$months[$month] = $start; # Set the timestamp
$start = strtotime('+1 month +1 day', strtotime($month));
# Convert to YYYYMM to compare
$check = intval(date('Ym', $start));
} while ($check <= $end);
CodonCache::write($key, $months, 'long');
}
return $months;
}
/**
无论你在哪里调用函数getMonthsSinceDate();你不小心把它传递给非数字的东西。它可能像一个用引号括起来的数字一样微妙,它会成为一个字符串,即
getMonthsSinceDate('111111')
PHP的date()
期望在整数UNIX时间戳中给出一个日期。如果您尝试将人类可读日期作为字符串传递,则会引发错误。
如果是,请使用strtotime()
将其转换为时间戳,如下所示:
$start = strtotime( $start );