Browse Source

TimeHelper returns invalid if date is null

erichowey 11 years ago
parent
commit
89d3ed7d0c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/View/Helper/TimeHelper.php

+ 5 - 1
src/View/Helper/TimeHelper.php

@@ -326,8 +326,12 @@ class TimeHelper extends Helper
      * @throws \InvalidArgumentException When the date cannot be parsed
      * @see \Cake\I18n\Time::i18nFormat()
      */
-    public function i18nFormat($date, $format = null, $invalid = false, $timezone = null)
+    public function i18nFormat($date = null, $format = null, $invalid = false, $timezone = null)
     {
+        if (empty($date)) {
+            return $invalid;
+        }
+
         try {
             $time = new Time($date, $timezone);
             return $time->i18nFormat($format, $timezone);