Index: Source/web/typo3conf/ext/timer/Classes/ViewHelpers/Format/DateViewHelper.php IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- Source/web/typo3conf/ext/timer/Classes/ViewHelpers/Format/DateViewHelper.php (revision 03affdb0480a9628d82f1c2ce81b4583346db4d2) +++ Source/web/typo3conf/ext/timer/Classes/ViewHelpers/Format/DateViewHelper.php (date 1604410248331) @@ -116,6 +116,7 @@ { $this->registerArgument('date', 'mixed', 'Either an object implementing DateTimeInterface or a string that is accepted by DateTime constructor'); $this->registerArgument('format', 'string', 'Format String which is taken to format the Date/Time', false, ''); + $this->registerArgument('zone', 'string', 'Timezone for the date, if it is different from the Timezone of TYPO3', false, ''); $this->registerArgument('base', 'mixed', 'A base time (an object implementing DateTimeInterface or a string) used if $date is a relative date specification. Defaults to current time.'); } @@ -129,6 +130,15 @@ */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { + $zone = date_default_timezone_get(); + if (isset($arguments['zone']) && (!empty($arguments['zone']))) { + $help = $arguments['zone']; + $zoneList = timezone_identifiers_list(); # list of (all) valid timezones + $zone = (in_array($help, $zoneList)? + $help: + date_default_timezone_get() + ); + } $format = $arguments['format']; $base = $arguments['base'] ?? GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'); if (is_string($base)) { @@ -157,11 +167,11 @@ $base = $base instanceof \DateTimeInterface ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base); $dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base); $date = new \DateTime('@' . $dateTimestamp); - $date->setTimezone(new \DateTimeZone(date_default_timezone_get())); } catch (\Exception $exception) { throw new Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579); } } + $date->setTimezone(new \DateTimeZone($zone)); if (strpos($format, '%') !== false) { return strftime($format, $date->format('U'));