One minute
Create DateTime from format without time
By adding an exclamation mark to the format argument, PHP will ignore the remaining date/time units and set them to zero.
echo (DateTimeImmutable::createFromFormat('Y-m-d', '2022-07-11'))->format('c') . PHP_EOL;
echo (DateTimeImmutable::createFromFormat('!Y-m-d', '2022-07-11'))->format('c') . PHP_EOL;
2022-07-11T08:35:53+02:00
2022-07-11T00:00:00+02:00
Read other posts