How to convert date to different format in php?
To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another.
1. Code:
format($format2);
return (false != $str) ? $str : null;
}
$str = convertDateToDifferentFormat("2022-06-10 06:32:16", "Y-m-d H:i:s", "d-m-Y");
echo($str);
?>
2. Example:
Input:
"2022-06-10 06:32:16", "Y-m-d H:i:s", "d-m-Y";
Output:
10-06-2022