From 6e37666c2f2490691a489be2d169d3f1c0277cef Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 7 Nov 2016 11:04:06 +0530 Subject: [PATCH] Get timezone only if required. --- src/View/Widget/DateTimeWidget.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index 20e61e40..312441bd 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -44,9 +44,11 @@ public function render(array $data, ContextInterface $context) } if ($val) { - $timestamp = $val->format('U'); - $dateTimeZone = new \DateTimeZone(date_default_timezone_get()); - $timezoneOffset = ($dateTimeZone->getOffset($val) / 60); + if ($timezoneAware) { + $timestamp = $val->format('U'); + $dateTimeZone = new \DateTimeZone(date_default_timezone_get()); + $timezoneOffset = ($dateTimeZone->getOffset($val) / 60); + } $val = $val->format($type === 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'); }