How does PHP handle the interpretation of dates as both dates and times when using strtotime()?

When using strtotime() in PHP, it can sometimes interpret dates as both dates and times, which may lead to unexpected results. To ensure that strtotime() only interprets the input as a date, you can append 'midnight' to the end of the date string. This will force strtotime() to treat the input as a date only.

$date = '2022-01-01';
$timestamp = strtotime($date . ' midnight');
echo date('Y-m-d H:i:s', $timestamp);