From eed448042228c3e016fbd5b9dd5b80c2c7dd8de0 Mon Sep 17 00:00:00 2001 From: Serhey Dolgushev Date: Wed, 21 Jul 2021 12:46:29 +0100 Subject: [PATCH] IBX-801: Fixed timezone for DateTime fields in content name pattern --- eZ/Publish/Core/FieldType/DateAndTime/Type.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eZ/Publish/Core/FieldType/DateAndTime/Type.php b/eZ/Publish/Core/FieldType/DateAndTime/Type.php index 7e8bc72c09..8d5c2a41a8 100644 --- a/eZ/Publish/Core/FieldType/DateAndTime/Type.php +++ b/eZ/Publish/Core/FieldType/DateAndTime/Type.php @@ -14,6 +14,7 @@ use eZ\Publish\SPI\FieldType\Value as SPIValue; use DateInterval; use DateTime; +use DateTimeZone; class Type extends FieldType { @@ -63,7 +64,10 @@ public function getName(SPIValue $value, FieldDefinition $fieldDefinition, strin return ''; } - return $value->value->format('D Y-d-m H:i:s'); + $dt = $value->value; + $dt->setTimezone(new DateTimeZone(date_default_timezone_get())); + + return $dt->format('D Y-d-m H:i:s'); } /**