Skip to content

Using non-UTC timezone corrupts dates imported from XML spreadsheet #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
tyomitch opened this issue Jun 2, 2020 · 0 comments · Fixed by #1506
Closed
2 of 3 tasks

Using non-UTC timezone corrupts dates imported from XML spreadsheet #1504

tyomitch opened this issue Jun 2, 2020 · 0 comments · Fixed by #1506

Comments

@tyomitch
Copy link
Contributor

tyomitch commented Jun 2, 2020

This is:

What is the expected behavior?

When importing an XML spreadsheet and saving it into XLSX, the dates should remain unchanged.

What is the current behavior?

The default timezone gets subtracted from all imported dates.

What are the steps to reproduce?

[root@centos PhpSpreadsheet]# cat test.xml
<?xml version="1.0" ?><?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  <Styles>
    <Style ss:ID="date"><NumberFormat ss:Format="Short Date"/></Style>
  </Styles>
  <Worksheet ss:Name="Test"><Table>
    <Row>
      <Cell ss:StyleID="date"><Data ss:Type="DateTime">2020-05-04T00:00:00</Data></Cell>
    </Row>
  </Table></Worksheet>
</Workbook>
[root@centos PhpSpreadsheet]# php
<?php require 'vendor/autoload.php';
date_default_timezone_set('Asia/Jerusalem');
$obj = (new \PhpOffice\PhpSpreadsheet\Reader\Xml)->load('test.xml');
(new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($obj))->save('test.xlsx');

Opening test.xml in Excel shows the correct date (04/05/2020)
Opening test.xlsx in Excel shows the corrupted date (03/05/2020 21:00:00)

Which versions of PhpSpreadsheet and PHP are affected?

PHP Version 7.3.13, PhpSpreadsheet 1.13.0

The root cause of this bug is #611

tyomitch added a commit to tyomitch/PhpSpreadsheet that referenced this issue Jun 2, 2020
vargedo added a commit to atmtk/PhpSpreadsheet that referenced this issue Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant