Automattic\WooCommerce\Internal\CLI\Migrator\Core
ProductsController::validate_date_filter
Validate date filter input.
Method of the class: ProductsController{}
No Hooks.
Returns
string|null. Formatted date string or null on error.
Usage
// private - for code of main (parent) class only $result = $this->validate_date_filter( $date_input, $filter_name ): ?string;
- $date_input(string) (required)
- The date input string.
- $filter_name(string) (required)
- The filter name for error messages.
ProductsController::validate_date_filter() ProductsController::validate date filter code WC 11.1.2
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 );
}