$dateString = '2021-11-26'; $formattedDate = date('d/m/Y', strtotime($dateString)); echo $formattedDate;
$dateString = '2021-11-26'; $formattedDate = date_create_from_format('Y-m-d', $dateString); echo date_format($formattedDate, 'F d, Y');Output: November 26, 2021 This example uses the PHP Utility dateFormat function to create a date object from the $dateString variable, which is in the format Y-m-d. The date_format function is then used to format the date in 'F d, Y' format, which stands for month day, year. The package library that contains the PHP Utility dateFormat function is the PHP Date and Time package. It is included in the core PHP language, so there is no need to install anything additional.