WC_Product_CSV_Importer::parse_date_field()publicWC 1.0

Parse dates from a CSV. Dates requires the format YYYY-MM-DD and time is optional.

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

Хуков нет.

Возвращает

Строку|null.

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

$WC_Product_CSV_Importer = new WC_Product_CSV_Importer();
$WC_Product_CSV_Importer->parse_date_field( $value );
$value(строка) (обязательный)
Field value.

Код WC_Product_CSV_Importer::parse_date_field() WC 8.7.0

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;
}