What are some best practices for handling null values in PHP 8.1 when using strtotime?

When using strtotime in PHP 8.1, it is important to handle null values properly to avoid errors. One way to do this is by checking if the input date is null before using strtotime function. If the date is null, you can set a default value or handle it accordingly to prevent any issues.

$date = null;

if ($date !== null) {
    $timestamp = strtotime($date);
    echo date('Y-m-d', $timestamp);
} else {
    echo "Date is null";
}