Home » Web Design and Development » PHP » Convert a Date from YYYY-MM-DD to DD-MM-YYYY Format in PHP ( Commonly used Indian date format )

Convert a Date from YYYY-MM-DD to DD-MM-YYYY Format in PHP ( Commonly used Indian date format )

Recently the source code we downloaded for one of our Android app. It was using the Birthdate format “YYYY-MM-DD” but most of our android app users are Indian and the most commonly used date format in India is DD-MM-YYYY, hence we needed to change the php API calls made by the app to change the date formats.

So, this date February 10 2021, i.e. 2021-02-10 can be converted to commonly used date format in India i.e. 10-02-2021 in php as,

<?php

current_displayed_date = "2021-02-10"
$timestamp = strtotime($current_displayed_date);
formatted_date = date("d-m-Y", $timestamp);
echo $formatted_date

?>

Reference – https://www.php.net/manual/en/function.strtotime.php

How To Change Date Format - MS Excel
How To Change Date Format - MS Excel

Leave a Comment