Home / PHP Tips Generated By ChatGPT / 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