From 17876dba48155ff82bd59ecd05cab3f8411fcb5d Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Wed, 23 May 2018 11:07:30 +0200
Subject: [PATCH] [TASK] Consistent date and time rendering in FormEngine

Use methods of BackendUtility to have a consistent look of date and
time fields in the backend.

Resolves: #85002
Releases: master, 8.7
Change-Id: I6f0b6aca1530524ff3f83922a1b4b2dd72b1ea84
Reviewed-on: https://review.typo3.org/57041
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
---
 .../backend/Classes/Form/Element/AbstractFormElement.php    | 6 +++---
 .../Tests/Unit/Form/Element/AbstractFormElementTest.php     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
index 5ac5869ce73d..8f26b9cd315e 100644
--- a/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
@@ -220,19 +220,19 @@ abstract class AbstractFormElement extends AbstractNode
             case 'datetime':
                 // compatibility with "eval" (type "input")
                 if ($itemValue !== '' && $itemValue !== null) {
-                    $itemValue = date('H:i d-m-Y', (int)$itemValue);
+                    $itemValue = BackendUtility::datetime((int)$itemValue);
                 }
                 break;
             case 'time':
                 // compatibility with "eval" (type "input")
                 if ($itemValue !== '' && $itemValue !== null) {
-                    $itemValue = gmdate('H:i', (int)$itemValue);
+                    $itemValue = BackendUtility::time((int)$itemValue, false);
                 }
                 break;
             case 'timesec':
                 // compatibility with "eval" (type "input")
                 if ($itemValue !== '' && $itemValue !== null) {
-                    $itemValue = gmdate('H:i:s', (int)$itemValue);
+                    $itemValue = BackendUtility::time((int)$itemValue);
                 }
                 break;
             case 'year':
diff --git a/typo3/sysext/backend/Tests/Unit/Form/Element/AbstractFormElementTest.php b/typo3/sysext/backend/Tests/Unit/Form/Element/AbstractFormElementTest.php
index 9ff377d72ea8..0dc0e810ecfc 100644
--- a/typo3/sysext/backend/Tests/Unit/Form/Element/AbstractFormElementTest.php
+++ b/typo3/sysext/backend/Tests/Unit/Form/Element/AbstractFormElementTest.php
@@ -82,7 +82,7 @@ class AbstractFormElementTest extends UnitTestCase
                     'format' => 'datetime',
                 ],
                 '1412358894',
-                '17:54 03-10-2014'
+                '03-10-14 17:54'
             ],
             'format to datetime with empty value' => [
                 [
-- 
GitLab