Automattic\WooCommerce\Admin

ReportExporter::format_date_range_bound │ private static │ WC 1.0

Format one end of a report's date range for display.

Метод класса: ReportExporter{}

Хуков нет.

Возвращает

string. The date in the store's date format, or an empty string when it cannot be read.

Использование

$result = ReportExporter::format_date_range_bound( $date );
$date(строка) (обязательный)
Date as Y-m-d.

Код ReportExporter::format_date_range_bound() WC 11.3.0

private static function format_date_range_bound( $date ) {
	// Read in the store's own timezone, so the date reads back as the merchant picked it and a
	// date format that names the timezone names theirs rather than UTC. Midday is a safe anchor.
	$parsed = \DateTimeImmutable::createFromFormat( 'Y-m-d H:i:s', $date . ' 12:00:00', wp_timezone() );

	if ( false === $parsed ) {
		return '';
	}

	return (string) wp_date( wc_date_format(), $parsed->getTimestamp() );
}