TimezoneService.php in Fullcalendar View 5.x
File
src/TimezoneService.php
View source
<?php
namespace Drupal\fullcalendar_view;
class TimezoneService {
public function __construct() {
}
public function utcToLocal($utc_date, $local_timezone, $format = 'Y-m-d\\TH:i:s', $offset = '') {
$utc = new \DateTimeZone("UTC");
$localTZ = new \DateTimeZone($local_timezone);
$date = new \DateTime($utc_date, $utc);
$date
->setTimezone($localTZ);
if (!empty($offset)) {
$date
->modify($offset);
}
return $date
->format($format);
}
}