What is the correct way to use the strtotime function in PHP?

When using the strtotime function in PHP, it is important to provide a date/time string that can be understood by the function. This means using a format that is recognized by strtotime, such as "YYYY-MM-DD" or "YYYY-MM-DD H:i:s". Additionally, it is recommended to check the return value of strtotime to ensure that the date/time string was parsed correctly.

$date_string = "2022-01-01";
$timestamp = strtotime($date_string);

if ($timestamp === false) {
    echo "Invalid date/time string";
} else {
    echo "Timestamp: " . $timestamp;
}