Excel how to use the `Y-m-d H:i:s` validation

340 views Asked by At

I use phpspreadsheet to write a xlsx file for user to import their data. And use custom datetime validation to validate the datetime field.

$datetime_validation = new DataValidation();
$datetime_validation->setShowErrorMessage(true);
$datetime_validation->setErrorTitle("unsupported datetime format");
$datetime_validation->setError("please input datetime in format 'Y-m-d H:i:s'(2020-09-12 13:56:00)");
$datetime_validation->setAllowBlank(false);
$datetime_validation->setType("custom");
$datetime_validation->setFormula1("yyyy-mm-dd hh:mm:ss");

But when I input like 2020-12-12 23:00:00, it prompt the error says the input data is not match the format.

0

There are 0 answers