Skip to content

Commit 99186cb

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60119 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 4356848 commit 99186cb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/wp-includes/functions.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ function mysql2date( $format, $date, $translate = true ) {
7070
* @since 1.0.0
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 ) {
78+
function 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 ) {
8181
return $gmt ? time() : time() + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
@@ -216,7 +216,6 @@ function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) {
216216
* @param int $timestamp A sum of Unix timestamp and timezone offset in seconds.
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 );
222221

@@ -235,10 +234,10 @@ function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) {
235234
*
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
*/
244243
function wp_date( $format, $timestamp = null, $timezone = null ) {

0 commit comments

Comments
 (0)