Changeset 51950
- Timestamp:
- 10/29/2021 04:50:29 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r51911 r51950 11 11 * Convert given MySQL date string into a different format. 12 12 * 13 * `$format` should be a PHP date format string.14 * 'U' and 'G' formats will return asum of timestamp with timezone offset.15 * `$date` is expected to be local time in MySQL format (`Y-m-d H:i:s`).13 * - `$format` should be a PHP date format string. 14 * - 'U' and 'G' formats will return an integer sum of timestamp with timezone offset. 15 * - `$date` is expected to be local time in MySQL format (`Y-m-d H:i:s`). 16 16 * 17 17 * Historically UTC time could be passed to the function to produce Unix timestamp. … … 25 25 * @param string $date Date string to convert. 26 26 * @param bool $translate Whether the return date should be translated. Default true. 27 * @return string|int|false Formatted date string or sum of Unix timestamp and timezone offset.27 * @return string|int|false Integer if `$format` is 'U' or 'G', string otherwise. 28 28 * False on failure. 29 29 */ … … 54 54 * Retrieves the current time based on specified type. 55 55 * 56 * The 'mysql' type will return the time in the format for MySQL DATETIME field.57 * The 'timestamp' typewill return the current timestamp or a sum of timestamp58 * and timezone offset, depending on `$gmt`.59 * Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d').60 * 61 * If $gmt is set to either '1' or 'true', then both types will use GMT time.62 * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.56 * - The 'mysql' type will return the time in the format for MySQL DATETIME field. 57 * - The 'timestamp' or 'U' types will return the current timestamp or a sum of timestamp 58 * and timezone offset, depending on `$gmt`. 59 * - Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d'). 60 * 61 * If `$gmt` is a truthy value then both types will use GMT time, otherwise the 62 * output is adjusted with the GMT offset for the site. 63 63 * 64 64 * @since 1.0.0 65 * 66 * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 65 * @since 5.3.0 Now returns an integer if `$type` is 'U'. Previously a string was returned. 66 * 67 * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', 'U', 67 68 * or PHP date format string (e.g. 'Y-m-d'). 68 69 * @param int|bool $gmt Optional. Whether to use GMT timezone. Default false. 69 * @return int|string Integer if $type is 'timestamp', string otherwise.70 * @return int|string Integer if `$type` is 'timestamp' or 'U', string otherwise. 70 71 */ 71 72 function current_time( $type, $gmt = 0 ) { … … 86 87 87 88 /** 88 * Retrieves the current time as an object with the timezone from settings.89 * Retrieves the current time as an object using the site's timezone. 89 90 * 90 91 * @since 5.3.0 … … 97 98 98 99 /** 99 * Retrieves the timezone from site settings as a string. 100 * 101 * Uses the `timezone_string` option to get a proper timezone if available, 102 * otherwise falls back to an offset. 100 * Retrieves the timezone of the site as a string. 101 * 102 * Uses the `timezone_string` option to get a proper timezone name if available, 103 * otherwise falls back to a manual UTC ± offset. 104 * 105 * Example return values: 106 * 107 * - 'Europe/Rome' 108 * - 'America/North_Dakota/New_Salem' 109 * - 'UTC' 110 * - '-06:30' 111 * - '+00:00' 112 * - '+08:45' 103 113 * 104 114 * @since 5.3.0 105 115 * 106 * @return string PHP timezone stringor a ±HH:MM offset.116 * @return string PHP timezone name or a ±HH:MM offset. 107 117 */ 108 118 function wp_timezone_string() { … … 126 136 127 137 /** 128 * Retrieves the timezone from site settingsas a `DateTimeZone` object.138 * Retrieves the timezone of the site as a `DateTimeZone` object. 129 139 * 130 140 * Timezone can be based on a PHP timezone string or a ±HH:MM offset.
Note: See TracChangeset
for help on using the changeset viewer.