From a91ffe612854d393487e3c811b917a8084465a60 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 23 Jun 2017 00:35:01 +0530 Subject: [PATCH] Use Date::parseDate() to parse date only string. DateFormatTrait::parseDate() by default uses format stored in $wordFormat for parsing date string. Value of Time::$wordFormat differs from Date::$wordFormat hence using the former to parse date strings results in incorrect date in the generated object. --- src/View/Widget/DateTimeWidget.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/View/Widget/DateTimeWidget.php b/src/View/Widget/DateTimeWidget.php index f737a0ec..f9d1d66f 100644 --- a/src/View/Widget/DateTimeWidget.php +++ b/src/View/Widget/DateTimeWidget.php @@ -2,6 +2,7 @@ namespace CrudView\View\Widget; use Cake\Core\Configure; +use Cake\I18n\Date; use Cake\I18n\I18n; use Cake\I18n\Time; use Cake\View\Form\ContextInterface; @@ -42,7 +43,7 @@ public function render(array $data, ContextInterface $context) if (!($val instanceof DateTimeInterface) && !empty($val)) { if ($type === 'date') { - $val = Time::parseDate($val); + $val = Date::parseDate($val); } elseif ($type === 'time') { $val = Time::parseTime($val); } else {