diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index fceac86ba..12b6d1909 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -121,7 +121,7 @@ foreach ( $offset_range as $offset ) { UTC time is %s'), date_i18n(__('Y-m-d G:i:s'), false, 'gmt')); ?> - %2$s'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'), current_time('timestamp'), 'gmt')); ?> + %2$s'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'))); ?>
@@ -148,12 +148,12 @@ foreach ( $offset_range as $offset ) { echo " checked='checked'"; $custom = FALSE; } - echo ' /> ' . date_i18n( $format, current_time('timestamp'), 'gmt' ) . "
\n"; + echo ' /> ' . date_i18n( $format ) . "
\n"; } echo ' ' . date_i18n( get_option('date_format'), current_time('timestamp'), 'gmt' ) . "\n"; + echo '/> ' . __('Custom:') . ' ' . date_i18n( get_option('date_format') ) . "\n"; echo "\t

" . __('Documentation on date formatting. Click "Save Changes" to update sample output.') . "

\n"; ?> @@ -180,12 +180,12 @@ foreach ( $offset_range as $offset ) { echo " checked='checked'"; $custom = FALSE; } - echo ' /> ' . date_i18n( $format, current_time('timestamp'), 'gmt' ) . "
\n"; + echo ' /> ' . date_i18n( $format ) . "
\n"; } echo ' ' . date_i18n( get_option('time_format'), current_time('timestamp'), 'gmt' ) . "\n"; + echo '/> ' . __('Custom:') . ' ' . date_i18n( get_option('time_format') ) . "\n"; ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index da927ffcf..73ffdba6f 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -116,16 +116,25 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { global $wp_locale; $i = $unixtimestamp; // Sanity check for PHP 5.1.0- - if ( false === $i || intval($i) < 0 ) - $i = time(); + if ( false === $i || intval($i) < 0 ) { + if ( ! $gmt ) + $i = current_time( 'timestamp' ); + else + $i = time(); + // we should not let date() interfere with our + // specially computed timestamp + $gmt = true; + } + + $datefunc = $gmt? 'gmdate' : 'date'; if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { - $datemonth = $wp_locale->get_month( date( 'm', $i ) ); + $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); - $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); + $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); - $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); - $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); + $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); + $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); $dateformatstring = ' '.$dateformatstring; $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring ); @@ -136,7 +145,7 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); } - $j = $gmt? @gmdate( $dateformatstring, $i ) : @date( $dateformatstring, $i ); + $j = @$datefunc( $dateformatstring, $i ); return $j; }