WordPress at a glance
function is not described

wc_rest_prepare_date_response() WC 2.6.0

Parses and formats a date for ISO8601/RFC3339.

Required WP 4.4 or later. See https://developer.wordpress.org/reference/functions/mysql_to_rfc3339/

No Hooks.

Return

String|null. ISO8601/RFC3339 formatted datetime.

Usage

wc_rest_prepare_date_response( $date, $utc );
$date(string|null|WC_DateTime) (required)
Date.
$utc(true|false)
Send false to get local/offset time.

Changelog

Since 2.6.0 Introduced.

Code of wc_rest_prepare_date_response() WC 5.3.0

<?php
function wc_rest_prepare_date_response( $date, $utc = true ) {
	if ( is_numeric( $date ) ) {
		$date = new WC_DateTime( "@$date", new DateTimeZone( 'UTC' ) );
		$date->setTimezone( new DateTimeZone( wc_timezone_string() ) );
	} elseif ( is_string( $date ) ) {
		$date = new WC_DateTime( $date, new DateTimeZone( 'UTC' ) );
		$date->setTimezone( new DateTimeZone( wc_timezone_string() ) );
	}

	if ( ! is_a( $date, 'WC_DateTime' ) ) {
		return null;
	}

	// Get timestamp before changing timezone to UTC.
	return gmdate( 'Y-m-d\TH:i:s', $utc ? $date->getTimestamp() : $date->getOffsetTimestamp() );
}