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.
$oldDate = "2018-05-22";
$changedDate = date("d-m-Y", strtotime($oldDate));
I hope you found your best solution....
Do you like below Tutorials ?
- Laravel 5.5 validation example with custom message
- Laravel 5.5 create zip archive file and download example
- Laravel 5.5 Jquery Ajax Request Example From Scratch
- Laravel 5.5 pagination example from scratch
- Ajax CRUD example in Laravel 5.5 application
- Class Form not found in Laravel 5.5
- Laravel 7.x and 6.x get last query log example
- Laravel 5.5 Image Upload example