Piwik\Site::getTimezoneFor PHP Method

getTimezoneFor() public static method

Returns the timezone of the site with the specified ID.
public static getTimezoneFor ( integer $idsite ) : string
$idsite integer The site ID.
return string
    public static function getTimezoneFor($idsite)
    {
        return self::getFor($idsite, 'timezone');
    }

Usage Example

 /**
  * This method takes the websites timezone into consideration when scheduling a task.
  * @param int $idSite
  * @param string $period  Eg 'day', 'week', 'month'
  * @return Daily|Monthly|Weekly
  * @throws \Exception
  * @ignore
  */
 public static function getScheduledTimeForSite($idSite, $period)
 {
     $arbitraryDateInUTC = Date::factory('2011-01-01');
     $midnightInSiteTimezone = date('H', Date::factory($arbitraryDateInUTC, Site::getTimezoneFor($idSite))->getTimestamp());
     $hourInUTC = (24 - $midnightInSiteTimezone) % 24;
     $schedule = self::getScheduledTimeForPeriod($period);
     $schedule->setHour($hourInUTC);
     return $schedule;
 }
All Usage Examples Of Piwik\Site::getTimezoneFor