Creating a Date from a String in PHP


Convert a string into a DateTime object using strtotime().

Source Code

$date = strtotime("2023-01-01");
echo date("Y-m-d", $date); // Outputs: 2023-01-01
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments