You are here

class TimezoneService in Fullcalendar View 8.2

Same name and namespace in other branches
  1. 8.3 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
  2. 8 src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
  3. 6.x src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService
  4. 5.x src/TimezoneService.php \Drupal\fullcalendar_view\TimezoneService

Class TimezoneService.

Hierarchy

Expanded class hierarchy of TimezoneService

1 string reference to 'TimezoneService'
fullcalendar_view.services.yml in ./fullcalendar_view.services.yml
fullcalendar_view.services.yml
1 service uses TimezoneService
fullcalendar_view.timezone_conversion_service in ./fullcalendar_view.services.yml
Drupal\fullcalendar_view\TimezoneService

File

src/TimezoneService.php, line 8

Namespace

Drupal\fullcalendar_view
View 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

Namesort descending Modifiers Type Description Overrides
TimezoneService::utcToLocal public function Return the value of the converted date from UTC date.
TimezoneService::__construct public function Constructor.