Make WordPress Core


Ignore:
Timestamp:
02/25/2014 05:00:36 PM (11 years ago)
Author:
nacin
Message:

Allow current_time() to accept a date format string, adding to 'timestamp' and 'mysql'.

props danielbachhuber.
fixes #21653.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r27158 r27259  
    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.
     
    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'.
     
    6465        case 'timestamp':
    6566            return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
     67            break;
     68        default:
     69            return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
    6670            break;
    6771    }
Note: See TracChangeset for help on using the changeset viewer.