ActionScheduler_ListTable::get_schedule_display_string
Get the scheduled date in a human friendly format.
Method of the class: ActionScheduler_ListTable{}
No Hooks.
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->get_schedule_display_string( $schedule );
- $schedule(ActionScheduler_Schedule) (required)
- Action's schedule.
ActionScheduler_ListTable::get_schedule_display_string() ActionScheduler ListTable::get schedule display string code WC 10.7.0
protected function get_schedule_display_string( ActionScheduler_Schedule $schedule ) {
$schedule_display_string = '';
if ( is_a( $schedule, 'ActionScheduler_NullSchedule' ) ) {
return __( 'async', 'woocommerce' );
}
if ( ! method_exists( $schedule, 'get_date' ) || ! $schedule->get_date() ) {
return '0000-00-00 00:00:00';
}
$next_timestamp = $schedule->get_date()->getTimestamp();
$schedule_display_string .= $schedule->get_date()->format( 'Y-m-d H:i:s O' );
$schedule_display_string .= '<br/>';
if ( gmdate( 'U' ) > $next_timestamp ) {
/* translators: %s: date interval */
$schedule_display_string .= sprintf( __( ' (%s ago)', 'woocommerce' ), self::human_interval( gmdate( 'U' ) - $next_timestamp ) );
} else {
/* translators: %s: date interval */
$schedule_display_string .= sprintf( __( ' (%s)', 'woocommerce' ), self::human_interval( $next_timestamp - gmdate( 'U' ) ) );
}
return $schedule_display_string;
}