I'm getting this error: "Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in C:...\myFile.php on line 24"
I've tried that code using strtotime instead of time():
$strDate = time();
$str = strtotime($strDate);
$date = date_create($str);
echo date_format($date, "Y/m/d");
And works: //--> 2018/12/31
But can't understand why, because both strtotime, and time return same Unix timestamps.
$dtObj = date_create(time(), timezone_open("Europe/Oslo"));
echo $dtObj . '</br>'; // Works ok
date_format($dtObj, "d-m-Y"); // This throws error
I expected the same result wiht both codes. Any clue about what's happening?