WP_REST_Revisions_Controller::prepare_date_response() WordPress Method

The WP_REST_Revisions_Controller::prepare_date_response() method is used to prepare the date response for a revision request. This method sets the correct timezone for the date, based on the blog's settings, and returns an array of data for the date.

WP_REST_Revisions_Controller::prepare_date_response( string $date_gmt, string|null $date = null ) #

Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.


Parameters

$date_gmt

(string)(Required)GMT publication time.

$date

(string|null)(Optional) Local publication time.

Default value: null


Top ↑

Return

(string|null) ISO8601/RFC3339 formatted datetime, otherwise null.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

	protected function prepare_date_response( $date_gmt, $date = null ) {
		if ( '0000-00-00 00:00:00' === $date_gmt ) {
			return null;
		}

		if ( isset( $date ) ) {
			return mysql_to_rfc3339( $date );
		}

		return mysql_to_rfc3339( $date_gmt );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.