I need to convert excel date to time stamp.
This is my code:
protected function convertExcelDateToTimestamp(int $offsetDays): ?int
{
$start = DateTime::createFromFormat("Y-m-d H:i:s", '1900-01-01 00:00:00');
$offsetDays = utf8_encode($offsetDays - 1);
$start->modify("+" .$offsetDays. " day");
if ($start->getTimestamp() === false) {
var_dump(DateTime::getLastErrors(), $offsetDays);
}
return ($start->getTimestamp());
}
I have 2 issues.
- For each dates I'm always have + one day of the right result.
- For this excel date : 20/07/2050 the timestamp === to false And I don't have issue in DateTime::getLastErrors.
Some one have any idea why my code is wrong?
Comments
Post a Comment