convert date to datetime php code example
Example 1: php convert string to date
$time = strtotime('10/16/2003');
$newformat = date('Y-m-d',$time);
echo $newformat;
// 2003-10-16
Example 2: convert date in php
$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));
Example 3: Convert String to Date and Date-Time in PHP
phpCopyecho $dateNew = date_create_from_format("m-d-Y", "03-08-2020")->format("Y-m-d");
//output: 2020/03/08