class TimezoneService in Fullcalendar View 8
Same name and namespace in other branches
- 8.3 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
- 8.2 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
- 6.x src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
- 5.x src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
Class TimezoneService.
Hierarchy
- class \Drupal\fullcalendar_view\TimezoneService
Expanded class hierarchy of TimezoneService
1 string reference to 'TimezoneService'
1 service uses TimezoneService
File
- src/
TimezoneService.php, line 8
Namespace
Drupal\fullcalendar_viewView source
class TimezoneService {
/**
* Constructor.
*/
public function __construct() {
}
/**
* Return the value of the converted date from UTC date.
*/
public function utcToLocal($utc_date, $local_timezone, $format = DATE_ATOM, $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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TimezoneService:: |
public | function | Return the value of the converted date from UTC date. | |
TimezoneService:: |
public | function | Constructor. |