Answer the question
In order to leave comments, you need to log in
PHP(7.2) error: Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given?
Hi all! The task is to parse the site. One of the elements contains a date and process it. Original date format: jmy . I'm converting to Ymd and I get an error Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given.
foreach($matches as $value){
$value = pq($value);
$date = $value->find('h4')->text();
$fdate = preg_replace("/[.]/", "-", $date);
$create_date = date_create_from_format('j-m-y', $fdate);
$formate_date = date_format($create_date, 'Y-m-d');
$end_date = strtotime($formate_date);
var_dump($date);
}
string(8) "09/06/18"
Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in C:\OSPanel\domains\pq\new.php on line 76
string(0) "" string(8) " 09/10/18"
Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in C:\OSPanel\domains\pq\new.php on line 76
string(0) "" string(8) "09/12/18"
Answer the question
In order to leave comments, you need to log in
date_create_from_format
Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question