Skip to content

Commit

Permalink
Improved BaseModel with date timezone support
Browse files Browse the repository at this point in the history
  • Loading branch information
libern committed Sep 17, 2016
1 parent 979c0ea commit 141871c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Someline/Base/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ protected function getAuthUserDateTimezone()
*/
public function setAttribute($key, $value)
{
if ($value && (in_array($key, $this->getDates()) || $this->isDateCastable($key))) {
$value = $this->fromDateTime($value);
}

if ($value instanceof Carbon && $this->timestamp_always_save_in_utc) {
$value->setTimezone('UTC');
}
Expand Down

0 comments on commit 141871c

Please sign in to comment.