Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue with incorrect date handling.

Fixes #2321
  • Loading branch information...
commit 0670b96c249246d01e0b1009d15580795386886d 1 parent 22352a0
@markstory markstory authored
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/Cake/Model/Model.php
View
12 lib/Cake/Model/Model.php
@@ -1184,12 +1184,14 @@ public function deconstruct($field, $data) {
}
}
- $format = $this->getDataSource()->columns[$type]['format'];
- $day = empty($date['Y']) ? null : $date['Y'] . '-' . $date['m'] . '-' . $date['d'] . ' ';
- $hour = empty($date['H']) ? null : $date['H'] . ':' . $date['i'] . ':' . $date['s'];
- $date = new DateTime($day . $hour);
if ($useNewDate && !empty($date)) {
- return $date->format($format);
+ $format = $this->getDataSource()->columns[$type]['format'];
+ foreach (array('m', 'd', 'H', 'i', 's') as $index) {
+ if (isset($date[$index])) {
+ $date[$index] = sprintf('%02d', $date[$index]);
+ }
+ }
+ return str_replace(array_keys($date), array_values($date), $format);
}
}
return $data;
Please sign in to comment.
Something went wrong with that request. Please try again.