What is the best way to format a date output in PHP, specifically in Joomla?

When formatting a date output in PHP, specifically in Joomla, the best way is to use the `JHtml::date` function provided by Joomla. This function allows you to easily format a date string according to the desired format. You can specify the format using PHP date format characters like 'Y' for year, 'm' for month, 'd' for day, etc.

// Get the current date
$date = JFactory::getDate();

// Format the date using the JHtml::date function
$formattedDate = JHtml::date($date, 'Y-m-d');

echo $formattedDate;