In PHP, what functions can be used to handle timestamps and ensure they are correctly formatted for display?

When working with timestamps in PHP, it is important to ensure they are correctly formatted for display to users. This can be achieved by using the date() function to format the timestamp according to the desired format. Additionally, the strtotime() function can be used to convert a date string into a Unix timestamp for manipulation.

// Example of formatting a timestamp for display
$timestamp = time(); // current timestamp
$formatted_date = date('Y-m-d H:i:s', $timestamp);
echo $formatted_date;

// Example of converting a date string into a timestamp
$date_string = '2022-12-31 23:59:59';
$timestamp = strtotime($date_string);
echo $timestamp;