Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

PHPExcel_Shared_Date::PHPToExcel does not work with objects implementing DateTimeInterface #907

Closed
cvoysey opened this issue May 27, 2016 · 1 comment

Comments

@cvoysey
Copy link

cvoysey commented May 27, 2016

When attempting to use PHPExcel_Shared_Date::PHPToExcel with a DateTimeImmutable false is being returned rather than the converted value.

<?php
$date = new DateTime();
$excel_date = PHPExcel_Shared_Date::PHPToExcel($date);
var_dump($excel_date);

$date = new DateTimeImmutable();
$excel_date = PHPExcel_Shared_Date::PHPToExcel($date);
var_dump($excel_date);
?>

The above code will output:

double(42517.61150463)
bool(false)

It appears that the method uses instanceof DateTime rather than instanceof DateTimeInterface.

@PowerKiKi
Copy link
Member

This has been done in PHPOffice/PhpSpreadsheet@850594c#diff-495ca961ee5a4a2ab5ae21e6a550a384L229 and more generally in DateTimeInterface are introduced in the context of PHPOffice/PhpSpreadsheet#7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants