Are there simpler methods for converting a date format to SQL without using a UNIX timestamp in PHP?

When converting a date format to SQL in PHP without using a UNIX timestamp, you can use the DateTime class to parse the date string and then format it in the desired SQL format. This method allows for more flexibility in handling different date formats and timezones.

$dateString = "2022-12-31";
$date = DateTime::createFromFormat('Y-m-d', $dateString);
$sqlFormattedDate = $date->format('Y-m-d H:i:s');

echo $sqlFormattedDate;