From b1a26ff336f535f0ce0477ab304414c9e74f798e Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Sun, 20 Apr 2014 19:08:08 +0530 Subject: [PATCH 1/2] Fix the Y2K38 bug Adds support for timestamps beyond year 2038. --- framework/base/Formatter.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/framework/base/Formatter.php b/framework/base/Formatter.php index 0907e1782c..d45551d339 100644 --- a/framework/base/Formatter.php +++ b/framework/base/Formatter.php @@ -342,18 +342,24 @@ class Formatter extends Component /** * Normalizes the given datetime value as one that can be taken by various date/time formatting methods. + * * @param mixed $value the datetime value to be normalized. * @return integer the normalized datetime value */ protected function normalizeDatetimeValue($value) { if (is_string($value)) { - return is_numeric($value) || $value === '' ? (int) $value : strtotime($value); + if (is_numeric($value) || $value === '') { + $value = (double)$value; + } else { + $date = new DateTime($value); + $value = $date->format('U'); + } + return $value; } elseif ($value instanceof DateTime || $value instanceof \DateTimeInterface) { - /** @var $value \DateTimeInterface */ - return $value->getTimestamp(); + return $value->format('U'); } else { - return (int) $value; + return (double)$value; } } From 82aedfb29558de87ed483d4c1b22d763861d50a3 Mon Sep 17 00:00:00 2001 From: Kartik Visweswaran Date: Sun, 20 Apr 2014 19:23:02 +0530 Subject: [PATCH 2/2] Update CHANGELOG.md --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 187dc2a8d0..67955eb05c 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.0-rc under development -------------------------- +- Bug #3194: Date formatter works only for timestamps in the year range 1970 to 2038. - Bug #2563: Theming is not working if the path map of the theme contains ".." or "." in the paths (qiangxue) - Bug #2801: Fixed the issue that GridView gets footer content before data cells content (ElisDN) - Bug #3042: `yii\widgets\Pjax` should end application right after it finishes responding to a pjax request (qiangxue)