Piwik\Plugin\Controller::getDateParameterInTimezone PHP Method

getDateParameterInTimezone() protected method

If the date is absolute, ie. YYYY-MM-DD, it will not be converted to the timezone.
protected getDateParameterInTimezone ( string $date, string $timezone ) : Date
$date string `'today'`, `'yesterday'`, `'YYYY-MM-DD'`
$timezone string The timezone to use.
return Piwik\Date
    protected function getDateParameterInTimezone($date, $timezone)
    {
        $timezoneToUse = null;
        // if the requested date is not YYYY-MM-DD, we need to ensure
        //  it is relative to the website's timezone
        if (in_array($date, array('today', 'yesterday'))) {
            // today is at midnight; we really want to get the time now, so that
            // * if the website is UTC+12 and it is 5PM now in UTC, the calendar will allow to select the UTC "tomorrow"
            // * if the website is UTC-12 and it is 5AM now in UTC, the calendar will allow to select the UTC "yesterday"
            if ($date == 'today') {
                $date = 'now';
            } elseif ($date == 'yesterday') {
                $date = 'yesterdaySameTime';
            }
            $timezoneToUse = $timezone;
        }
        return Date::factory($date, $timezoneToUse);
    }