Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.

Commit c4782b6

Browse files
author
MarkBaker
committed
General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel
1 parent a1dee8f commit c4782b6

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Classes/PHPExcel/Shared/Date.php

+7
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,17 @@ public static function PHPToExcel($dateValue = 0, $adjustToTimezone = false, $ti
182182
{
183183
$saveTimeZone = date_default_timezone_get();
184184
date_default_timezone_set('UTC');
185+
186+
$timezoneAdjustment = ($adjustToTimezone) ?
187+
PHPExcel_Shared_TimeZone::getTimezoneAdjustment($timezone ? $timezone : $saveTimeZone, $dateValue) :
188+
0;
189+
185190
$retValue = false;
186191
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
192+
$dateValue->add(new DateInterval('PT' . $timezoneAdjustment . 'S'));
187193
$retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s'));
188194
} elseif (is_numeric($dateValue)) {
195+
$dateValue += $timezoneAdjustment;
189196
$retValue = self::FormattedPHPToExcel(date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue), date('H', $dateValue), date('i', $dateValue), date('s', $dateValue));
190197
} elseif (is_string($dateValue)) {
191198
$retValue = self::stringToExcel($dateValue);

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Planned for 1.8.2
3434
- Feature: (Tomino2112) Work Item GH-808 - MemoryDrawing not working in HTML writer
3535
- General: (rentalhost) Work Item GH-575 - Excel 2007 Reader freezes because of conditional formatting
3636
- Bugfix: (vitalyrepin) Pull Request 869 - c:max and c:min elements shall NOT be inside c:orientation elements
37+
- General: (sim642) Pull Request 489 - Implement actual timezone adjustment into PHPExcel_Shared_Date::PHPToExcel
3738

3839

3940
2015-04-30 (v1.8.1):

0 commit comments

Comments
 (0)