Error date format when import

I Have datetime type data with format “yyyy-mm-dd“ but when it import from excel file error show

"Could not convert PHP Value DateImmutable"

all my PHPMaker project before this version error with the same problem

I Try to put this script on server event → row import

// assume the date field name is DT as your case above
$var = $row["DT"];
$row["DT"] = date("Y-m-d", strtotime($var));

still have same problem…

Any Idea?

Thank You

Change this part:
$row["DT"] = date("Y-m-d", strtotime($var));

to:
$row["DT"] = ConvertToString(date("Y-m-d", strtotime($var)));

If $row["DT"] is not a valid date time string, you should not pass it to strtotime().

You better check what the value of $row["DT"] is. If it is from a Excel cell formatted as "Date", it is not a valid date time string, you need to convert yourself. You may google "what is an excel date" for more info.

Also, it is better to set a DateTime object to the field directly.