/** * * @param type $format * @return \IntlDateFormatter * @throws Exception */ protected function getIntlDateFormater($format) { if (\is_string($format)) { $format = \constant('\\IntlDateFormatter::' . \strtoupper($format)); } else { if (!\is_numeric($format)) { throw new Exception('Format must be an string or IntlDateFormater Int Value'); } } $locale = \Symfony\Component\Locale\Locale::getDefault(); $tz = $this->userManager->getTimezone(); $fmt = new \IntlDateFormatter($locale, $format, $format, $tz->getName(), \IntlDateFormatter::GREGORIAN); return $fmt; }
/** * get a ISO8601 String ( Date with Timezone and Time Information ) * @param \DateTime $datetime * @return null|string */ public function getISO8601ForUser(\DateTime $datetime = null) { if ($datetime) { $datetime->setTimezone($this->userManager->getTimezone()); return $datetime->format(\DateTime::ISO8601); } return null; }