WC_Product_CSV_Importer::parse_date_field( string $value )
Parse dates from a CSV.
Description Description
Dates requires the format YYYY-MM-DD and time is optional.
Parameters Parameters
- $value
-
(Required) Field value.
Return Return
(string|null)
Source Source
File: includes/import/class-wc-product-csv-importer.php
public function parse_date_field( $value ) {
if ( empty( $value ) ) {
return null;
}
if ( preg_match( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])([ 01-9:]*)$/', $value ) ) {
// Don't include the time if the field had time in it.
return current( explode( ' ', $value ) );
}
return null;
}