fix timezone problem

This commit is contained in:
DavidBadura
2015-04-22 12:00:47 +00:00
parent cc02f7aa60
commit 09c3ea1e5e
3 changed files with 10 additions and 8 deletions

View File

@@ -70,6 +70,9 @@ class CarbonHandler implements SubscribingHandlerInterface
*/
public function serializeCarbon(VisitorInterface $visitor, Carbon $date, array $type, Context $context)
{
$date = clone $date;
$date->setTimezone($this->defaultTimezone);
return $visitor->visitString($date->format($this->getFormat($type)), $type, $context);
}
@@ -94,6 +97,8 @@ class CarbonHandler implements SubscribingHandlerInterface
throw new RuntimeException(sprintf('Invalid datetime "%s", expected format %s.', $data, $format));
}
$datetime->setTimezone(new \DateTimeZone(date_default_timezone_get()));
return $datetime;
}