What are some common functions in PHP for working with timestamps?
When working with timestamps in PHP, there are several common functions that can be used to manipulate, format, and compare timestamps. Some of these functions include `time()` to get the current Unix timestamp, `strtotime()` to parse a date/time string into a timestamp, `date()` to format a timestamp into a readable date/time string, and `strtotime()` to convert a timestamp into a Unix timestamp.
// Get the current Unix timestamp
$currentTimestamp = time();
// Parse a date/time string into a timestamp
$timestamp = strtotime('2022-01-01 12:00:00');
// Format a timestamp into a readable date/time string
$formattedDate = date('Y-m-d H:i:s', $timestamp);
// Convert a timestamp into a Unix timestamp
$newTimestamp = mktime(date('H', $timestamp), date('i', $timestamp), date('s', $timestamp), date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));