# rest_get_date_with_gmt()

URL: https://chugunov.pro/api-wordpress/functions/rest_get_date_with_gmt/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.4.0.

## Сигнатура

```php
rest_get_date_with_gmt( string $date, bool $is_utc = false ): array|null
```

## Описание

См. alsorest_parse_date()

## Параметры

- `$date` `string` — обязательный. Метка времени в формате RFC3339.
- `$is_utc` `bool` — необязательный, по умолчанию `false`. Следует ли интерпретировать переданную дату как UTC.

## Возвращаемое значение

`array|null` — 0 string Локальная строка даты-времени. 1 string Строка даты-времени в UTC.

## Исходный код

Файл: `wp-includes/rest-api.php:1384`

```php
function rest_get_date_with_gmt( $date, $is_utc = false ) {
	/*
	 * Whether or not the original date actually has a timezone string
	 * changes the way we need to do timezone conversion.
	 * Store this info before parsing the date, and use it later.
	 */
	$has_timezone = preg_match( '#(Z|[+-]\d{2}(:\d{2})?)$#', $date );

	$date = rest_parse_date( $date );

	if ( false === $date ) {
		return null;
	}

	/*
	 * At this point $date could either be a local date (if we were passed
	 * a *local* date without a timezone offset) or a UTC date (otherwise).
	 * Timezone conversion needs to be handled differently between these two cases.
	 */
	if ( ! $is_utc && ! $has_timezone ) {
		$local = gmdate( 'Y-m-d H:i:s', $date );
		$utc   = get_gmt_from_date( $local );
	} else {
		$utc   = gmdate( 'Y-m-d H:i:s', $date );
		$local = get_date_from_gmt( $utc );
	}

	return array( $local, $utc );
}
```

## История изменений

- 4.4.0 — Introduced.

## Связанные

Использует: [`rest_parse_date`](https://chugunov.pro/api-wordpress/functions/rest_parse_date/), [`get_gmt_from_date`](https://chugunov.pro/api-wordpress/functions/get_gmt_from_date/), [`get_date_from_gmt`](https://chugunov.pro/api-wordpress/functions/get_date_from_gmt/).
Используется в: `WP_REST_Posts_Controller::prepare_item_for_database`, `WP_REST_Comments_Controller::prepare_item_for_database`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/rest_get_date_with_gmt/
