Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dhaval_patel's avatar

Encounter date in phpspreadsheet

Hey Guys, How can I identify if a specific column in XLS sheet has a date? I am using a phpspreadsheet.

0 likes
3 replies
jlrdw's avatar

I don't understand, you should know the data type of the column it seems. Can you be more detailed? And even if the column was a date but people entered it as text, you could still use some string functions to properly format it to a mysql date format.

Dhaval_patel's avatar

@jlrdw Thanks for the answer

I am using phpspreadsheet library to convert XLS file,and I am using PHP Date time object to convert dates, but how can I encountered which fields has date or not ?

I am using below code to convert dates

$value = $worksheet->getValue();
$date = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($value);

Please or to participate in this conversation.