Skip to content

Commit

Permalink
Get timezone only if required.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 7, 2016
1 parent 90d7824 commit 6e37666
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/View/Widget/DateTimeWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 6e37666

Please sign in to comment.