convert mysql date to dd mm yyyy format in php – How to change date format in PHP?

convert mysql date to dd mm yyyy format in php. You can first use the PHP strtotime() function to convert any textual datetime into Unix timestamp.

convert mysql date to dd mm yyyy format in php

convert mysql date to dd mm yyyy format in php or php changr date format or convert dd/mm/yyyy to yyyy-mm-dd in mysql php Examples for Convert a date YYYY-MM-DD to DD-MM-YYYY in PHP.

Change YYYY-MM-DD to DD-MM-YYYY

  

Change YYYY-MM-DD to MM-DD-YYYY

In the below example, i have date 2022-02-26 in YYYY-MM-DD format, and i will convert this to 02-26-2022 (MM-DD-YYYY) format.

  

Don’t miss : How To Change Date Format In PHP?

Change DD-MM-YYYY to YYYY-MM-DD

In the below example, i have date 25-07-2015 in DD-MM-YYYY format, and i will convert this to 2015-07-25 (YYYY-MM-DD) format.

  

Result

New date format is: 2015-07-25 (YYYY-MM-DD)

Change DD-MM-YYYY to YYYY/MM/DD

Suppose i have date 25-07-2015 in DD-MM-YYYY format separated by dash (-) sign. i want to convert this to 2015/07/25 (YYYY/MM/DD) format

  

Result

 date format is: 2015/07/25 (YYYY/MM/DD)

Change date time to another format

  

php date format dd-mm-yyyy

In PHP, you can format a date into the dd-mm-yyyy format using the date() function along with the strtotime() function to parse a date string. Here’s how you can do it:

$dateString = "2024-02-12"; // Example date string in yyyy-mm-dd format

// Parse the date string and format it as dd-mm-yyyy
$formattedDate = date("d-m-Y", strtotime($dateString));

echo $formattedDate; // Output: 12-02-2024

In this example:

  • We start with a date string "2024-02-12" in the standard yyyy-mm-dd format.
  • We use strtotime() to parse the date string into a Unix timestamp.
  • We then use date() to format the timestamp into the desired dd-mm-yyyy format.

This will output "12-02-2024", representing the date in dd-mm-yyyy format.

I hope you get an idea about convert mysql date to dd mm yyyy format in php.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment