appTimezone = $appTimezone; $this->cachetTimezone = $cachetTimezone; } /** * Create a Carbon instance from a specific format. * * @param string $format * @param string $time * * @throws \InvalidArgumentException * * @return \Carbon\Carbon */ public function create($format, $time) { return Date::createFromFormat($format, $time, $this->cachetTimezone)->setTimezone($this->appTimezone); } /** * Create a Carbon instance from a specific format. * * We're also going to make sure the timezone information is correct. * * @param string $format * @param string $time * * @throws \InvalidArgumentException * * @return \Carbon\Carbon */ public function createNormalized($format, $time) { return Date::createFromFormat($format, $time)->setTimezone($this->appTimezone); } /** * Make a Carbon instance from a string. * * @param string|null $time * * @throws \InvalidArgumentException * * @return \Carbon\Carbon */ public function make($time = null) { return (new Date($time))->setTimezone($this->cachetTimezone); } /** * Return the abbreviated timezone. * * @return string */ public function getTimezone() { $dateTime = new Date(); $dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone)); return $dateTime->format('T'); } }