我試圖格式化的日期和它讓我看到以下消息:笨 - 消息:日期時間:: __結構():無法解析的時間字符串 - 消息:非合式數值遇到
Severity: Notice
Message: A non well formed numeric value encountered
我已經嘗試了所有這些,並繼續傳遞消息。
echo date('Y-m-d', '01/01/2017');
echo date('Y-m-d', strtotime(str_replace('/','-', '01/01/2017')));
$start_date = new DateTime("2017-01-01 20:00:00");
$end_date = new DateTime("2018-05-05 22:00:00");
$between = $start_date->diff($end_date);
echo 'between: '.$between->y.' years, <br>'
.$between->m.' months, <br>'
.$between->d.' days <br>'
.$between->days.' days <br>';
echo "<pre>"; print_r($between);
此功能以實現:
public function between_days($start_date, $end_date)
{
$start_date = strtotime($start_date);
$start_date = strtotime(date('d/m/Y'));
$end_date = strtotime($end_date);
$between = abs($end_date - $start_date);
$total = $between/86400;
$days = intval($total);
return $days;
}
代碼工作正常。 –
https://eval.in/788224 –
如果正確,它的工作原理是完美的,但它向我展示了這些消息,它只是在codeiginiter沒有更多。 –