public function TimezoneService::utcToLocal in Fullcalendar View 6.x
Same name and namespace in other branches
- 8.3 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService::utcToLocal()
- 8 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService::utcToLocal()
- 8.2 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService::utcToLocal()
- 5.x src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService::utcToLocal()
Return the value of the converted date from UTC date.
File
- src/
TimezoneService.php, line 19
Class
- TimezoneService
- Class TimezoneService.
Namespace
Drupal\fullcalendar_viewCode
public function utcToLocal($utc_date, $local_timezone, $format = 'Y-m-d\\TH:i:s', $offset = '') {
// UTC timezone.
$utc = new \DateTimeZone("UTC");
// Local time zone.
$localTZ = new \DateTimeZone($local_timezone);
// Date object in UTC timezone.
$date = new \DateTime($utc_date, $utc);
$date
->setTimezone($localTZ);
if (!empty($offset)) {
$date
->modify($offset);
}
return $date
->format($format);
}