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 8.6.1

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 ) ) {
		throw new \InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'woocommerce' ), $action_id ) ); //phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment
	}
	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 );
	}
}