Skip to content

Commit

Permalink
Merge pull request #533 from srsbiz/copy-timezone
Browse files Browse the repository at this point in the history
Copy exact timezone from \DateTime object
  • Loading branch information
jpfuentes2 committed Apr 22, 2016
2 parents 815a112 + c52232f commit 5f211a3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function cast($value, $connection)
return $value;

if ($value instanceof \DateTime)
return new DateTime($value->format('Y-m-d H:i:s T'));
return new DateTime($value->format('Y-m-d H:i:s'), $value->getTimezone());

return $connection->string_to_datetime($value);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public function assign_attribute($name, $value)

// convert php's \DateTime to ours
if (!($value instanceof DateTime) && $value instanceof \DateTime)
$value = new DateTime($value->format('Y-m-d H:i:s T'));
$value = new DateTime($value->format('Y-m-d H:i:s'), $value->getTimezone());

// make sure DateTime values know what model they belong to so
// dirty stuff works when calling set methods on the DateTime object
Expand Down

0 comments on commit 5f211a3

Please sign in to comment.