getOffset( new DateTime( "@$time" ) ) - $site_dtz->getOffset( new DateTime( "@$time" ) ); //echo "
tz_offset=$tz_offset
"; $datetime_ = date( 'Y-m-d H:i:s', strtotime( $datetime ) + $tz_offset * $delta + $offset ); } else { // If there is no support for timezones, there's nothing we can do. // Just check the date and return it if it makes sense. $datetime_ = date( 'Y-m-d H:i:s', strtotime( $datetime ) ); } return $datetime_; } /** * Returns a datetime formatted as a date without time component. * * @param string $datetime the datetime to format as a date * @return formatted date */ static function formatDate( $datetime ) { return date( self::$dateFormat, strtotime( $datetime ) ); } /** * Returns a datetime formatted as a time without date component. * * @param string $datetime the datetime to format as a time * @return formatted time */ static function formatTime( $datetime ) { return date( self::$timeFormat, strtotime( $datetime ) ); } /** * Returns a formatted datetime with a date and a time component. * * @param string $datetime the datetime to format * @return formatted datetime */ static function formatDatetime( $datetime ) { return date( self::$datetimeFormat, strtotime( $datetime ) ); } static function getServerDateTimeZone() { $default_tz = date_default_timezone_get(); $default_dtz = new DateTimeZone( $default_tz ); return $default_dtz; } static function getUserDateTimeZone() { $tzstring = get_option('timezone_string'); $site_dtz = new DateTimeZone( $tzstring ); return $site_dtz; } /** * Substitutes deprecated wp_timezone_supported(). * The current (WP 5.2.1) just returns true. Unfortunately we can * not assume as of yet that everybody will run their WP on * PHP 5 >= 5.2.0 so we maintain this for a while. * @see wp_timezone_supported() * @link http://core.trac.wordpress.org/ticket/16970 */ static function timezone_supported() { $support = false; if ( function_exists( 'date_create' ) && // PHP 5 >= 5.2.0 function_exists( 'date_default_timezone_set' ) && // PHP 5 >= 5.1.0 function_exists( 'timezone_identifiers_list' ) && // PHP 5 >= 5.2.0 function_exists( 'timezone_open' ) && // PHP 5 >= 5.2.0 function_exists( 'timezone_offset_get' ) // PHP 5 >= 5.2.0 ) { $support = true; } return apply_filters( 'timezone_support', $support ); } } ?>