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.

OOCalc parsing date/time cells and timeZone bug #140

Open
@Strate

Description

@Strate

PHPExcel/Reader/OOCalc.php has this code:

$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
//......
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj);

There is a bug, second setting of $timezoneObj is not needed, because DateTime object was created with UTC timeZone, but second timeZone is hardcoded for London.

Simply run this code to understand what I mean:

date_default_timezone_set('Europe/Moscow');
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
$dateObj = new DateTime('2012-04-01 00:00:00', $GMT);
echo $dateObj->format( 'Y-m-d H:i:s' ); // prints expected `2012-04-01 00:00:00` string
$dateObj->setTimeZone($timezoneObj);
echo $dateObj->format( 'Y-m-d H:i:s' ); // prints unexpected `2012-04-01 01:00:00` string, 1 hour difference

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions