diff --git a/changelog.txt b/changelog.txt index f7474b88..2511de98 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Planned for 1.9 - Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer - General: (rentalhost) Work Item GH-575 - Excel 2007 Reader freezes because of conditional formatting - Bugfix: (vitalyrepin) Pull Request 869 - c:max and c:min elements shall NOT be inside c:orientation elements +- General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel 2015-04-30 (v1.8.1): diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index d1ea52d1..0cf94b89 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -184,10 +184,17 @@ class Date { $saveTimeZone = date_default_timezone_get(); date_default_timezone_set('UTC'); + + $timezoneAdjustment = ($adjustToTimezone) ? + PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) : + 0; + $retValue = false; if ((is_object($dateValue)) && ($dateValue instanceof \DateTime)) { + $dateValue->add(new DateInterval('PT' . $timezoneAdjustment . 'S')); $retValue = self::formattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')); } elseif (is_numeric($dateValue)) { + $dateValue += $timezoneAdjustment; $retValue = self::formattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue)); } elseif (is_string($dateValue)) { $retValue = self::stringToExcel($dateValue);