In this post we will show you date format in php, hear for date format php we will give you demo and example for implement.
Throughout, In this tutorial you’ll learn php date.now.This article goes in detailed on implementing php format date from mysql.If you want to learn string to date php. So, from this post, you can find step by step process of doing php date to timestamp.
How do I Convert Date Format in PHP?
There are the Following The simple About how to print current date in php? Full Information With Example and source code.
As I will cover this Post with live Working example to develop how to get current date and time in php?
1. Change YYYY-MM-DD => MM-DD-YYYY
Here we have date yyyy-mm-dd (β2021-04-25β) format and converting it to mm-dd-yyyy (β04-25-2021β) format.
$origDate = "2021-04-25"; $newDate = date("m-d-Y", strtotime($origDate)); echo $newDate; //results : 04-25-2021
2. Change YYYY-MM-DD => DD-MM-YYYY
Here we have date yyyy-mm-dd (β2021-04-25β) format and converting it to dd-mm-yyyy (β25-04-2021β) format.
$origDate = "2021-04-25"; $newDate = date("d-m-Y", strtotime($origDate)); echo $newDate; //results 25-04-2021
3. Change DD/MM/YYYY => YYYY-MM-DD
If you have slashes in date format like β25/04/2021β and need to convert / with hyphens (-). The following example will help you to convert DD/MM/YYYY (β25/04/2021β) to YYYY-MM-DD (2021-04-25).
$origDate = "25/04/2021"; $date = str_replace('/', '-', $origDate ); $newDate = date("Y-m-d", strtotime($date)); echo $newDate; //result : 2021-04-25
Web Programming Tutorials Example with Demo
I hope you get an idea about how to convert date format in php?.
I would like to have feedback on my pakainfo.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.