timezone_offset_get example

function wp_timezone_override_offset() {
    $timezone_string = get_option( 'timezone_string' );
    if ( ! $timezone_string ) {
        return false;
    }

    $timezone_object = timezone_open( $timezone_string );
    $datetime_object = date_create();
    if ( false === $timezone_object || false === $datetime_object ) {
        return false;
    }
    return round( timezone_offset_get( $timezone_object$datetime_object ) / HOUR_IN_SECONDS, 2 );
}

/** * Sort-helper for timezones. * * @since 2.9.0 * @access private * * @param array $a * @param array $b * @return int */

  protected function getOffset($time$timezone) {
    // Date-only fields do not have a time zone or offset from UTC associated     // with them. For relative (i.e. 'offset') comparisons, we need to compute     // the user's offset from UTC for use in the query.     $origin_offset = 0;
    if ($this->dateFormat === DateTimeItemInterface::DATE_STORAGE_FORMAT && $this->value['type'] === 'offset') {
      $origin_offset = $origin_offset + timezone_offset_get(new \DateTimeZone(date_default_timezone_get())new \DateTime($timenew \DateTimeZone($timezone)));
    }

    return $origin_offset;
  }

}
Home | Imprint | This part of the site doesn't use cookies.