Convert current time set here to another time zone

@param *string     $zone   valid UTC, GMT, PHP Location or TZ Abbreviation
@param string|null $format format

@return string|int
327866
public function convertTo(string $zone, string $format = null)
    {
        $time = $this->time + $this->calculateOffset($zone);

        if (!is_null($format)) {
            return date($format, $time);
        }

        return $time;
    }
87695
public static function normalizeFormat($format)
    {
        static $datesPatterns = null;
        static $timesPatterns = null;

        if ($datesPatterns === null || $timesPatterns === null) {
            $datesPatterns = '/(' . implode('|', array_keys(static::$_map['date'])) . ')/';
            $timesPatterns = '/(' . implode('|', array_keys(static::$_map['time'])) . ')/';
        }

        $format = trim($format);
        $format = preg_replace("/'([^']+)'/", '', $format); // remove quotes
        $format = preg_replace('/\s{2,}/', ' ', $format); // remove double spaces
        $format = trim($format);
        list($dateFormat, $timeFormat) = explode(' ', "{$format} ");

        // normalize formats
        $dateFormat = preg_replace_callback($datesPatterns, function ($matches) {
            return static::$_map['date'][$matches[1]];
        }, $dateFormat);

        $timeFormat = preg_replace_callback($timesPatterns, function ($matches) {
            return static::$_map['time'][$matches[1]];
        }, $timeFormat);

        $format = trim($dateFormat . ' ' . $timeFormat);

        return $format;
    }
333465
public function format($format = null) {
        if(is_null($format)) {
            $format = $this->getFormatter()->getDateTimeFormat();
        }
        return date($format, $this->getEpoch());
    }
391133
public function formatLocalized($format)
    {
        // Check for Windows to find and replace the %e modifier correctly.
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format); // @codeCoverageIgnore
        }

        $formatted = strftime($format, strtotime($this->toDateTimeString()));

        return static::$utf8 ? utf8_encode($formatted) : $formatted;
    }
799215
protected function getOffsetFromLocation(string $zone): string
    {
        $zone = new DateTimeZone($zone);
        $gmt = new DateTimeZone(self::GMT);

        return $zone->getOffset(new \DateTime('now', $gmt));
    }
264134
private function toTimezone($zone) {
		return isset($this->windowsTimezones[$zone]) ? $this->windowsTimezones[$zone] : $zone;
	}
337916
public function getTimezoneHourOffset($origin_tz = 'UTC', $format = 'h') {
        $remote_tz = 'UTC';
        if ($origin_tz === 'UTC') {
            return 0 . 'h';
        }
        $origin_dtz = new \DateTimeZone($origin_tz);
        $remote_dtz = new \DateTimeZone($remote_tz);
        $origin_dt = new \DateTime("now", $origin_dtz);
        $remote_dt = new \DateTime("now", $remote_dtz);

        $offset =  $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt);
        return $offset / 3600 . $format;
    }
657875
public function format($format, $timezone)
    {
        $date = clone $this->date;
        $date->setTimezone(new DateTimeZone($timezone));
        return $date->format($format);
    }
899878
public function currentInterval($format = null)
    {

        // Relative time formatting
        $abbreviated = [
            'pluraling' => false,
            'spacing' => false,
            'labels' => ['now', 's', 'm', 'h', 'd', 'm', 'y'],
        ];

        // Figure stuff out
        if ($this->isRunning()) {
            $interval = $this->WORKER_SLEEP_SECS;
        } else {
            $check = Cache::get($this->HEARTBEAT_CRON_KEY);
            if (empty($check)) {
                $interval = 'uncertain';
            } else {
                $interval = $check->interval;
            }
        }

        // Format it
        if (!is_numeric($interval)) {
            return $interval;
        }
        switch ($format) {
            case 'raw':
                return $interval;

            case 'abbreviated':
                return Library\Utils\Text::timeElapsed(time() - $interval, $abbreviated);

            default:
                return Library\Utils\Text::timeElapsed(time() - $interval);
        }
    }
734268
public static function formatOther($timestamp, $format = 'eeee')
    {
        $instance=self::$_instance;
        $fmt=new IntlDateFormatter($instance->_currentLocale, 0, 0);
        $fmt->setPattern($format);
        return $fmt->format($timestamp);
    }
190186
public function getTime(?int $format = null): float
    {
        $result = $this->endTime - $this->startTime;

        return $this->formatTime($result, $format);
    }
205283
public static function validateTimeFormat($format)
    {
        $format = str_replace(array_keys(static::$_map['time']), '', $format); // remove placeholders
        $format = preg_replace("/'(.*)'/", '', $format); // remove literals
        $format = preg_replace('/[^a-z]/i', '', $format);
        $format = trim($format);

        return empty($format);
    }
1195047
public function timeAgo($time = null, $format = null) {
		if (empty($time)) {
			$time = time();
		}
		if (empty($format)) {
			$format = '%x %X';
		}

		$result = $this->Html->tag(
			'time',
			$this->Time->i18nFormat($time, $format),
			[
				'data-toggle' => 'timeago',
				'datetime' => date('c', $this->Time->fromString($time)),
				'class' => 'help'
			]
		);

		return $result;
	}
535962
public function format($format)
    {
        $format = preg_replace_callback('/(?<!\\\\)[DlFM]/', array($this, '_translate'), $format);
        return $this->_date->format($format);
    }
1205965
public function format_local($format) {
        // Configure the timezone to account for timezone and/or daylight savings time
        $timezone = new DateTimeZone(date_default_timezone_get());
        $this->setTimezone($timezone);

        $timestamp = $this->getTimestamp();
        return strftime($format, $timestamp);
    }
58036
public function formatTZ($format)
    {
        $out = '';

        switch ($format) {
            case self::TZ_ID:
                $out = $this->format('e');
                break;

            case self::TZ_SHORT:
            case self::TZ_LONG:
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (
                    isset($abbreviations[$id]) &&
                    isset($abbreviations[$id]['st'])
                ) {
                    $out = $abbreviations[$id]['st'];
                }
                break;

            case self::TZ_DST_SHORT:
            case self::TZ_DST_LONG:
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (isset($abbreviations[$id])) {
                    if (isset($abbreviations[$id]['dt'])) {
                        $out = $abbreviations[$id]['dt'];
                    } else {
                        $out = $abbreviations[$id]['st'];
                    }
                }
                break;

            case self::TZ_CURRENT_SHORT:
            case self::TZ_CURRENT_LONG:
                $out = $this->format('T');
                break;

            case self::TZ_COMBINED:
                $out = array();
                $id = $this->format('e');
                $abbreviations = self::getTimeZoneAbbreviations();
                if (isset($abbreviations[$id])) {
                    if (isset($abbreviations[$id]['st'])) {
                        $out[] = $abbreviations[$id]['st'];
                    }
                    if (isset($abbreviations[$id]['dt'])) {
                        $out[] = $abbreviations[$id]['dt'];
                    }
                }
                $out = implode('/', $out);
                break;
        }

        return $out;
    }
1273811
public function format($format = null) {
        if(is_null($format)) {
            $format = $this->getFormatter()->getCurrentFormat();
        }
        return date($format, $this->getEpoch());
    }