What are the advantages and disadvantages of formatting dates in PHP versus storing pre-formatted dates in a database?

When working with dates in PHP, one option is to format the dates directly in the PHP code before displaying them to the user. Another option is to store pre-formatted dates in the database and retrieve them as needed. The advantage of formatting dates in PHP is that it allows for more flexibility in how the dates are displayed, as you can easily change the format in one central location. However, storing pre-formatted dates in the database can improve performance by reducing the need to format dates repeatedly in the PHP code.

// Formatting date in PHP
$date = "2022-01-15";
$formatted_date = date("F j, Y", strtotime($date));
echo $formatted_date;