From 551274ebbcad59f6d1e600880cac5e024bd47c0e Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 29 Jan 2019 14:05:30 -0800 Subject: [PATCH] Fixed #3748 --- CHANGELOG-v3.md | 5 +++++ src/helpers/DateTimeHelper.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 925ebb197c0..a88d2a00751 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -1,5 +1,10 @@ # Release Notes for Craft CMS 3.x +## Unreleased + +### Fixed +- Fixed an error that occured when creating a Table field with a Date column. ([#3748](https://github.com/craftcms/cms/issues/3748)) + ## 3.1.6 - 2019-01-29 ### Added diff --git a/src/helpers/DateTimeHelper.php b/src/helpers/DateTimeHelper.php index de6b1f4363b..2ce3eba0835 100644 --- a/src/helpers/DateTimeHelper.php +++ b/src/helpers/DateTimeHelper.php @@ -91,7 +91,7 @@ class DateTimeHelper * - `timezone` – A [valid PHP timezone](http://php.net/manual/en/timezones.php). If set, this will override * the assumed timezone per `$assumeSystemTimeZone`. * - * @param mixed $value The value that should be converted to a DateTime object. + * @param string|int|array|null $value The value that should be converted to a DateTime object. * @param bool $assumeSystemTimeZone Whether it should be assumed that the value was set in the system timezone if * the timezone was not specified. If this is `false`, UTC will be assumed. * @param bool $setToSystemTimeZone Whether to set the resulting DateTime object to the system timezone. @@ -104,6 +104,10 @@ public static function toDateTime($value, bool $assumeSystemTimeZone = false, bo return $value; } + if (!$value) { + return false; + } + $defaultTimeZone = ($assumeSystemTimeZone ? Craft::$app->getTimeZone() : 'UTC'); if (is_array($value)) {