Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.
This repository was 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

Description

@cvoysey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions