How can the mktime function be used to convert a date to a timestamp in PHP?

The mktime function in PHP can be used to convert a date to a timestamp by specifying the individual components of the date (hour, minute, second, month, day, year) as arguments. This function returns a Unix timestamp which represents the number of seconds since the Unix Epoch (January 1, 1970). By using mktime, you can easily convert a date to a timestamp for further manipulation or comparison.

// Convert a date to a timestamp using mktime
$timestamp = mktime(0, 0, 0, 10, 1, 2022); // October 1, 2022
echo $timestamp; // Output: 1664620800