wp_next_scheduled

Retrieve the next timestamp for an event.

Description

(false|int) wp_next_scheduled( (string) $hook, (array) $args = array() ); 

Returns (false|int)

The Unix timestamp of the next time the scheduled event will occur.

Parameters (2)

0. $hook (string)
Action hook to execute when event is run.
1. $args — Optional. (array) => array()
Arguments to pass to the hook's callback function.

Usage

  1. if ( !function_exists( 'wp_next_scheduled' ) ) { 
  2. require_once ABSPATH . WPINC . '/cron.php'; 
  3.  
  4. // Action hook to execute when event is run. 
  5. $hook = ''; 
  6.  
  7. // Optional. Arguments to pass to the hook's callback function. 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_next_scheduled($hook, $args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/cron.php  
  1. function wp_next_scheduled( $hook, $args = array() ) { 
  2. $crons = _get_cron_array(); 
  3. $key = md5(serialize($args)); 
  4. if ( empty($crons) ) 
  5. return false; 
  6. foreach ( $crons as $timestamp => $cron ) { 
  7. if ( isset( $cron[$hook][$key] ) ) 
  8. return $timestamp; 
  9. return false;