summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorSergey Biryukov <sergeybiryukov@git.wordpress.org>2025-04-01 16:41:05 +0000
committerSergey Biryukov <sergeybiryukov@git.wordpress.org>2025-04-01 16:41:05 +0000
commit99186cb02f97f367ad859eeba278cfc962904c71 (patch)
treea1f087697300023e86d2cbd50d6af45dd3e56265 /src
parent435684846ca3fe038a53b6b5f372da32aba153e2 (diff)
downloadwordpress-99186cb02f97f367ad859eeba278cfc962904c71.tar.gz
wordpress-99186cb02f97f367ad859eeba278cfc962904c71.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/wp-includes/functions.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index ec6cc616dc..ec248f5b98 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -70,12 +70,12 @@ function mysql2date( $format, $date, $translate = true ) {
* @since 1.0.0
* @since 5.3.0 Now returns an integer if `$type` is 'U'. Previously a string was returned.
*
- * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U',
- * or PHP date format string (e.g. 'Y-m-d').
- * @param int|bool $gmt Optional. Whether to use GMT timezone. Default false.
+ * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U',
+ * or PHP date format string (e.g. 'Y-m-d').
+ * @param bool $gmt Optional. Whether to use GMT timezone. Default false.
* @return int|string Integer if `$type` is 'timestamp' or 'U', string otherwise.
*/
-function current_time( $type, $gmt = 0 ) {
+function current_time( $type, $gmt = false ) {
// Don't use non-GMT timestamp, unless you know the difference and really need to.
if ( 'timestamp' === $type || 'U' === $type ) {
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 ) {
* @param int $timestamp A sum of Unix timestamp and timezone offset in seconds.
* Might be without offset if input omitted timestamp but requested GMT.
* @param bool $gmt Whether to use GMT timezone. Only applies if timestamp was not provided.
- * Default false.
*/
$date = apply_filters( 'date_i18n', $date, $format, $timestamp, $gmt );
@@ -235,10 +234,10 @@ function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) {
*
* @global WP_Locale $wp_locale WordPress date and time locale object.
*
- * @param string $format PHP date format.
- * @param int $timestamp Optional. Unix timestamp. Defaults to current time.
- * @param DateTimeZone $timezone Optional. Timezone to output result in. Defaults to timezone
- * from site settings.
+ * @param string $format PHP date format.
+ * @param int|null $timestamp Optional. Unix timestamp. Defaults to current time.
+ * @param DateTimeZone|null $timezone Optional. Timezone to output result in. Defaults to timezone
+ * from site settings.
* @return string|false The date, translated if locale specifies it. False on invalid timestamp input.
*/
function wp_date( $format, $timestamp = null, $timezone = null ) {