1To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another.
2
3Change YYYY-MM-DD to DD-MM-YYYY
4<? php.
5$currDate = "2020-04-18";
6$changeDate = date("d-m-Y", strtotime($currDate));
7echo "Changed date format is: ". $changeDate. " (MM-DD-YYYY)";
8?>
1$currDate = "2020-08-25";
2$changeDate = date("d-m-Y", strtotime($currDate));
3echo $changedDate;
1<?php
2 #https://moneyconvert.net/
3 $source = '2012-07-31';
4 $date = new DateTime($source);
5 echo $date->format('d.m.Y'); // 31.07.2012
6 echo $date->format('d-m-Y'); // 31-07-2012
7?>