WordPress.org

Make WordPress Core

Ticket #21653: 21653.2.patch

File 21653.2.patch, 1.2 KB (added by danielbachhuber, 16 months ago)

Offer PHP date format support to current_time()

  • wp-includes/functions.php

     
    4646 * 
    4747 * The 'mysql' type will return the time in the format for MySQL DATETIME field. 
    4848 * The 'timestamp' type will return the current timestamp. 
     49 * Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d'). 
    4950 * 
    5051 * If $gmt is set to either '1' or 'true', then both types will use GMT time. 
    5152 * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option. 
    5253 * 
    5354 * @since 1.0.0 
    5455 * 
    55  * @param string $type Either 'mysql' or 'timestamp'. 
     56 * @param string $type 'mysql', 'timestamp', or PHP date format string (e.g. 'Y-m-d'). 
    5657 * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false. 
    5758 * @return int|string String if $type is 'gmt', int if $type is 'timestamp'. 
    5859 */ 
     
    6465                case 'timestamp': 
    6566                        return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); 
    6667                        break; 
     68                default: 
     69                        return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); 
     70                        break; 
    6771        } 
    6872} 
    6973