ActionScheduler_DBStore::get_date_gmt()protectedWC 1.0

Get the GMT schedule date for an action.

Method of the class: ActionScheduler_DBStore{}

No Hooks.

Return

\DateTime. The GMT date the action is scheduled to run, or the date that it ran.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_date_gmt( $action_id );
$action_id(int) (required)
Action ID.

ActionScheduler_DBStore::get_date_gmt() code WC 9.3.3

protected function get_date_gmt( $action_id ) {
	/** @var \wpdb $wpdb */
	global $wpdb;
	$record = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->actionscheduler_actions} WHERE action_id=%d", $action_id ) );
	if ( empty( $record ) ) {
		/* translators: %s is the action ID */
		throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s: we were unable to determine the date of this action. It may may have been deleted by another process.', 'woocommerce' ), $action_id ) );
	}
	if ( self::STATUS_PENDING === $record->status ) {
		return as_get_datetime_object( $record->scheduled_date_gmt );
	} else {
		return as_get_datetime_object( $record->last_attempt_gmt );
	}
}