Make WordPress Core

Ticket #9588: 9588.18.diff

File 9588.18.diff, 2.2 KB (added by ryan, 15 years ago)
  • wp-includes/functions.php

     
    5959 * @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
    6060 */
    6161function current_time( $type, $gmt = 0 ) {
    62         switch ( $type ) {
    63                 case 'mysql':
    64                         return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
    65                         break;
    66                 case 'timestamp':
    67                         return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
    68                         break;
     62        if ( function_exists('date_default_timezone_set') ) {
     63                // Use the PHP5 DateTime support. The timezone is already correctly set.
     64                switch ( $type ) {
     65                        case 'mysql':
     66                                return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : date( 'Y-m-d H:i:s' );
     67                                break;
     68                        case 'timestamp':
     69                                return ( $gmt ) ? gmdate('U') : time();
     70                                break;
     71                }
     72        } else {
     73                // No PHP5 DateTime support. Add in gmt_offset.
     74                switch ( $type ) {
     75                        case 'mysql':
     76                                return ( $gmt ) ? gmdate( 'Y-m-d H:i:s') : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
     77                                break;
     78                        case 'timestamp':
     79                                return ( $gmt ) ? time() : ( time() + ( get_option( 'gmt_offset' ) * 3600 ) );
     80                                break;
     81                }
    6982        }
    7083}
    7184
  • wp-settings.php

     
    1818set_magic_quotes_runtime(0);
    1919@ini_set('magic_quotes_sybase', 0);
    2020
    21 if ( function_exists('date_default_timezone_set') )
    22         date_default_timezone_set('UTC');
    23 
    2421/**
    2522 * Turn register globals off.
    2623 *
     
    719716// Load in support for template functions which the theme supports
    720717require_if_theme_supports( 'post-thumbnails', ABSPATH . WPINC . '/post-thumbnail-template.php' );
    721718
     719// Set the timezone
     720if ( function_exists('date_default_timezone_set') ) {
     721        if ( $timezone_string = get_option( 'timezone_string' ) )
     722                @date_default_timezone_set( $timezone_string );
     723        else
     724                @date_default_timezone_set(ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC');
     725}
     726
    722727/**
    723728 * Runs just before PHP shuts down execution.
    724729 *