
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP program to change date format
To change date format in PHP, the code is as follows−
Example
<?php $date = "2019-11-11 05:25 PM"; echo "Displaying date...
"; echo "Date = $date"; echo "
Displaying updated date...
"; echo date('Y-m-d H:i', strtotime($date. ' + 20 days')); ?>
Output
This will produce the following output−
Displaying date... Date = 2019-11-11 05:25 PM Displaying updated date... 2019-12-01 17:25
Example
Let us now see another example−
<?php $date = date_create("2019-11-11"); echo "Displaying date...
"; echo date_format($date,"Y/m/d H:i:s"); ?>
Output
This will produce the following output−
Displaying date... 2019/11/11 00:00:00
- Related Articles
- PHP program to change the date format
- Is there a way to change the date format in php?
- Change date format in MongoDB
- Change date format (in DB or output) to dd/mm/yyyy in PHP MySQL?
- How to change date time format in HTML5?
- How to change American date format in Excel?
- How to change date format with DATE_FORMAT() in MySQL?
- Best way to change the date format in MySQL SELECT?
- How to change date and time format in Android sqlite?
- Change the curdate() (current date) format in MySQL
- Java Program to format date with SimpleDateFormat
- Java Program to format date with DateFormat.FULL
- Java Program to format date with System.out.format
- Java Program to format date in mm-dd-yyyy hh:mm:ss format
- Change date format in MySQL database table to d/m/y

Advertisements