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

In this article

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

Description

Duplicate of WP_REST_Revisions_Controller::prepare_date_response() .

Parameters

$date_gmtstringrequired
GMT publication time.
$datestring|nulloptional
Local publication time.

Default:null

Return

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

Source


if ( rest_is_field_included( 'author', $fields ) ) {
	$data['author'] = (int) $post->post_author;
}

if ( rest_is_field_included( 'date', $fields ) ) {
	$data['date'] = $this->prepare_date_response( $post->post_date_gmt, $post->post_date );
}

if ( rest_is_field_included( 'date_gmt', $fields ) ) {
	$data['date_gmt'] = $this->prepare_date_response( $post->post_date_gmt );

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.