when i edit the data and after the submission of that form, i got an error like
ERROR - 2019-05-19 12:40:26 --> Severity: error --> Exception: Call to a member function format() on boolean please help me out of this....
i followed this but its not working Call to a member function format() on boolean in PHP LARAVEL
$datetime = DateTime::createFromFormat('d/m/Y H:i:s', $date . ' ' . $time);
$created_at = $datetime->format('Y-m-d H:i:s');
$record = ['created_at' => $created_at,];
The issue is with the $date
or $time
string(s) you are trying to pass into DateTime::createFromFormat
. They should look similar to the following to work properly:
$date = "15/05/2019";
$time = "10:28:33";
$datetime = DateTime::createFromFormat('d/m/Y H:i:s', $date . ' ' . $time);
$created_at = $datetime->format('Y-m-d H:i:s');
$record = ['created_at' => $created_at,];
print_r($record);
Output:
Array
(
[created_at] => 2019-05-15 10:28:33
)
The error message explains it all quite detailed.
ERROR - 2019-05-19 12:40:26
Meaning the input is in format "Y-m-d H:i:s"
But your code says 'd/m/Y H:i:s'
.
Either your $date variable is wrong or your code is wrong.
Most likely your code should be with format: 'Y-m-d H:i:s'