How to change date format in PHP?29 Aug 2024 | 2 min read To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another. For example - we have stored date in MM-DD-YYYY format in a variable, and we want to change it to DD-MM-YYYY format. We can achieve this conversion by using strtotime() and date() function. These are the built-in functions of PHP. The strtotime() first converts the date into the seconds, and then date() function is used to reconstruct the date in any format. Below some examples are given to convert the date format. Change YYYY-MM-DD to DD-MM-YYYYIn the below example, we have date 2019-09-15 in YYYY-MM-DD format, and we will convert this to 15-09-2019 in DD-MM-YYYY format. Output New date format is: 15-09-2019 (DD-MM-YYYY) Change YYYY-MM-DD to MM-DD-YYYYIn the below example, we have date 2019-02-26 in YYYY-MM-DD format, and we will convert this to 02-26-2019 (MM-DD-YYYY) format. Output New date format is: 02-26-2019 (MM-DD-YYYY) Change DD-MM-YYYY to YYYY-MM-DDIn the below example, we have date 17-07-2012 in DD-MM-YYYY format, and we will convert this to 2012-07-17 (YYYY-MM-DD) format. Output New date format is: 2012-07-17 (YYYY-MM-DD) Change DD-MM-YYYY to YYYY/MM/DDSuppose we have date 17-07-2012 in DD-MM-YYYY format separated by dash (-) sign. We want to convert this to 2012/07/17 (YYYY/MM/DD) format, which will be separated by the slash (/). In the below example, DD-MM-YYYY format is converted to the YYYY-MM-DD format, and also dashes (-) will be replaced with slash (/) sign. Output date format is: 2012/07/17 (YYYY/MM/DD) Change date time to another formatHere in the below example, we will convert the date format MM-DD-YYYY to YYYY-DD-MM format and 12 hours time clock to 24 hours time clock. Output New date time format is: 2019/13/06 17:35:00 Next TopicHow to get the IP address in PHP |
What is Multiple Inheritance? Multiple inheritances are one of the four pillars of OOP object-oriented programming, consisting of a child class or a subclass inheriting the traits from multiple parent classes or superclasses. These classes can reuse the code derived from their parent class after enabling a relationship...
7 min read
PHP has a built-in feature called gmp_random() that makes a random number. The range of numeric values will be between zero and the number of bits per limb, multiplied by the limiter. A limb is the internal functionality or mechanism of the GMP function. The number of...
4 min read
Composer is an application that is used for dependency management in standard format in PHP. Composer lets you declare the libraries on which your PHP project depends and manage it for you. It installs and updates the libraries that you need for your project. By default,...
5 min read
PHP has a built-in function called GMP gmp_clrbit() that clears a bit of a GMP number (GNU Multiple Precision). The gmp_clrbit() function turns off the bit in a GMP number that is at a certain index. The least important bit of the index is zero, so...
2 min read
The Imagick::addImage() method is a PHP built-in function for adding new images to the Imagick object image list. Following the operation, the iterator is relocated to the end of the list. This function adds a new picture to an Imagick object based on the source object's...
5 min read
In this section, we are going to learn how to upload the file by clicking on the button in the PHP dropzone. We will use submit button to upload one or more files in PHP Dropzone. When we upload one or more than one file using drag...
3 min read
In this section, we are going to learn about multiple image uploads in PHP. We will use Ajax and jQuery to do this. Sometimes our project needs the option of multiple image upload. If we don't have knowledge about PHP, this example will be very useful...
2 min read
PHP Imagecreate( ) Function Image create ( ) function is another inbuilt PHP function mainly used to create a new image. The function returns the given image in a specific size. We need to define the width and height of the required image. Instead of the image...
4 min read
is a range of crucial instruments that make it simple to have at nearby servers so you can create or fabricate Web Applications on your PC. In the event that you are making improvement on the web application, having a is a wonderful way,...
7 min read
For developers who are new to creating websites, knowing how to connect to MySQL using PHP scripts will be very helpful. This allows you to view, modify, and control the tables in the MySQL database. In this article, we'll show you the simplest ways to...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India