Specify UTC timezone as localc/Excel expect

This commit is contained in:
Oded Arbel 2020-09-05 12:14:34 +03:00 committed by GitHub
parent 84540b66f5
commit c9d4b60d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,8 +208,8 @@ class WorksheetManager implements WorksheetManagerInterface
$value = $cell->getValue();
if ($value instanceof \DateTime) {
$datevalue = substr($value->setTimezone(new \DateTimeZone("UTC"))->format(\DateTimeInterface::W3C),0,-6);
$data .= ' office:value-type="date" calcext:value-type="date" office:date-value="' . $datevalue . '">';
$data .= '<text:p>' . $datevalue . '</text:p>';
$data .= ' office:value-type="date" calcext:value-type="date" office:date-value="' . $datevalue . 'Z">';
$data .= '<text:p>' . $datevalue . 'Z</text:p>';
} else if ($value instanceof \DateInterval) {
// workaround for missing DateInterval::format('c'), see https://stackoverflow.com/a/61088115/53538
static $f = ['M0S', 'H0M', 'DT0H', 'M0D', 'Y0M', 'P0Y', 'Y0M', 'P0M'];