format_gmt_offset example

$timezone_info = array();

        if ( $tz_string ) {
            try {
                $tz = new DateTimeZone( $tz_string );
            } catch ( Exception $e ) {
                $tz = '';
            }

            if ( $tz ) {
                $now                   = new DateTime( 'now', $tz );
                $formatted_gmt_offset  = $this->format_gmt_offset( $tz->getOffset( $now ) / HOUR_IN_SECONDS );
                $tz_name               = str_replace( '_', ' ', $tz->getName() );
                $timezone_info['abbr'] = $now->format( 'T' );

                $timezone_info['description'] = sprintf(
                    /* translators: 1: Timezone name, 2: Timezone abbreviation, 3: UTC abbreviation and offset, 4: UTC offset. */
                    __( 'Your timezone is set to %1$s (%2$s), currently %3$s (Coordinated Universal Time %4$s).' ),
                    $tz_name,
                    '<abbr>' . $timezone_info['abbr'] . '</abbr>',
                    '<abbr>UTC</abbr>' . $formatted_gmt_offset,
                    $formatted_gmt_offset
                );
            }
Home | Imprint | This part of the site doesn't use cookies.