Make WordPress Core

Changeset 60119


Ignore:
Timestamp:
04/01/2025 04:41:05 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Docs: Correct documentation for current_time(), date_i18n(), and wp_date().

Includes:

  • Standardizing on the bool type for the $gmt parameter between current_time() and date_i18n().
  • Documenting null as an acceptable value for $timestamp and $timezone parameters in wp_date().
  • Removing a redundant note on the $gmt parameter for the date_i18n filter, as defaults are normally only documented for function parameters.

Follow-up to [1001], [9616], [28109], [45901].

Props dilipbheda.
Fixes #63207.

File:
1 edited

Legend:

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

    r60085 r60119  
    7171 * @since 5.3.0 Now returns an integer if `$type` is 'U'. Previously a string was returned.
    7272 *
    73  * @param string   $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U',
    74  *                       or PHP date format string (e.g. 'Y-m-d').
    75  * @param int|bool $gmt  Optional. Whether to use GMT timezone. Default false.
     73 * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U',
     74 *                     or PHP date format string (e.g. 'Y-m-d').
     75 * @param bool  $gmt  Optional. Whether to use GMT timezone. Default false.
    7676 * @return int|string Integer if `$type` is 'timestamp' or 'U', string otherwise.
    7777 */
    78 function current_time( $type, $gmt = 0 ) {
     78function current_time( $type, $gmt = false ) {
    7979    // Don't use non-GMT timestamp, unless you know the difference and really need to.
    8080    if ( 'timestamp' === $type || 'U' === $type ) {
     
    217217     *                          Might be without offset if input omitted timestamp but requested GMT.
    218218     * @param bool   $gmt       Whether to use GMT timezone. Only applies if timestamp was not provided.
    219      *                          Default false.
    220219     */
    221220    $date = apply_filters( 'date_i18n', $date, $format, $timestamp, $gmt );
     
    236235 * @global WP_Locale $wp_locale WordPress date and time locale object.
    237236 *
    238  * @param string       $format    PHP date format.
    239  * @param int          $timestamp Optional. Unix timestamp. Defaults to current time.
    240  * @param DateTimeZone $timezone  Optional. Timezone to output result in. Defaults to timezone
    241  *                                from site settings.
     237 * @param string            $format    PHP date format.
     238 * @param int|null          $timestamp Optional. Unix timestamp. Defaults to current time.
     239 * @param DateTimeZone|null $timezone  Optional. Timezone to output result in. Defaults to timezone
     240 *                                     from site settings.
    242241 * @return string|false The date, translated if locale specifies it. False on invalid timestamp input.
    243242 */
Note: See TracChangeset for help on using the changeset viewer.