WC_Customer_Download_Data_Store::adjust_date_for_db()privateWC 1.0

Adjust a date value to be inserted in the database.

Method of the class: WC_Customer_Download_Data_Store{}

No Hooks.

Return

String. The date converted to 'Y-m-d' format.

Usage

// private - for code of main (parent) class only
$result = $this->adjust_date_for_db( $date );
$date(mixed) (required)
The date value. Can be a WC_DateTime, a timestamp, or anything else that "date" recognizes.

WC_Customer_Download_Data_Store::adjust_date_for_db() code WC 8.7.0

private function adjust_date_for_db( $date ) {
	if ( 'WC_DateTime' === get_class( $date ) ) {
		$date = $date->getTimestamp();
	}

	$adjusted_date = date( 'Y-m-d', $date ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date

	if ( $adjusted_date ) {
		return $adjusted_date;
	}

	$msg = sprintf( __( "I don't know how to get a date from a %s", 'woocommerce' ), is_object( $date ) ? get_class( $date ) : gettype( $date ) );
	throw new Exception( $msg );
}