WordPress at a glance
function is not described

WP_REST_Posts_Controller::prepare_date_response() protected WP 4.7.0

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

{} It's a method of the class: WP_REST_Posts_Controller{}

No Hooks.

Return

String/null. ISO8601/RFC3339 formatted datetime.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_date_response( $date_gmt, $date );
$date_gmt(string) (required)
GMT publication time.
$date(string/null)
Local publication time.
Default: null

Changelog

Since 4.7.0 Introduced.

Code of WP_REST_Posts_Controller::prepare_date_response() WP 5.5.2

<?php
protected function prepare_date_response( $date_gmt, $date = null ) {
	// Use the date if passed.
	if ( isset( $date ) ) {
		return mysql_to_rfc3339( $date );
	}

	// Return null if $date_gmt is empty/zeros.
	if ( '0000-00-00 00:00:00' === $date_gmt ) {
		return null;
	}

	// Return the formatted datetime.
	return mysql_to_rfc3339( $date_gmt );
}