Automattic\WooCommerce\Internal\CLI\Migrator\Core

ProductsController::validate_date_filterprivateWC 1.0

Validate date filter input.

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

Хуков нет.

Возвращает

Строку|null. Formatted date string or null on error.

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

// private - только в коде основоного (родительского) класса
$result = $this->validate_date_filter( $date_input, $filter_name ): ?string;
$date_input(строка) (обязательный)
The date input string.
$filter_name(строка) (обязательный)
The filter name for error messages.

Код ProductsController::validate_date_filter() WC 10.7.0

private function validate_date_filter( string $date_input, string $filter_name ): ?string {
	$timestamp = strtotime( $date_input );
	if ( false === $timestamp ) {
		WP_CLI::warning(
			sprintf( 'Invalid date format for --%s: %s', $filter_name, $date_input )
		);
		return null;
	}

	return gmdate( 'Y-m-d\\TH:i:s\\Z', $timestamp );
}