Hi Guys,
Today, i will let you know how to change date format like Y-m-d to d-m-Y or yyyy-mm-dd to dd-mm-yyyy etc as you want to change. So no worry here you will see simple and easy example for php developer.
Actually, i was working on my old core php project and i need to change date format Y-m-d to d-m-Y. we always use date picker and we need to convert date formate for save data in mysql database. reason is mysql date accept y-m-d So. Here same issue i have i require to change date format using PHP.
Here we will use strtotime() php date function and date(). strtotime() is a amazing php date function. strtotime() will help to convert date formate in php. So basically looks bellow example, how it simple and it will help you a lot.
PHP Example:
<?php
$oldDate = "2018-05-22";
$changedDate = date("d-m-Y", strtotime($oldDate));
print_r($changedDate);
?>
I hope you found your best solution....
Do you like below Tutorials ?
- Angular Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?
- Angular 9 Image Upload with Crop Example
- Files Upload on Button Click in PHP Dropzone Example
- PHP Dropzone Allow only One File to Upload Example
- PHP Dropzone Allow only Images to Upload Example
- PHP Dropzone Delete Uploaded File Example
- Livewire CRUD Laravel 7 Example