I would need to know how much time is left between now and the next time a specifc Cron Job is done.

For another answer I built a basic cron inspector plugin which can be found here.

Reason I'm asking is that I'm already that wasted from working that I can't think straight at the moment. :/

Thanks in advance.


1 Answer 1


Edit: wp_next_scheduled() returns the timestamp of the next scheduled job of a specified wp-cron job-arguments pair.

Please note that this differs slightly in functionality to the answer below, in that you have to provide the arguments passed to cron job's callback (if it has any). The original answer would provide the time of the next specified job regardless of the arguments it would run with.

The cron array (_get_cron_array()) returns an array of cron jobs indexed by timestamp (each timestamp will have an array of crons associated with it - i.e. those jobs which shall be triggered).

 * Returns the time in seconds until a specified cron job is scheduled.
 *@param string $cron_name The name of the cron job
 *@return int|bool The time in seconds until the cron job is scheduled. False if
 *it could not be found.
function sh_get_next_cron_time( $cron_name ){

    foreach( _get_cron_array() as $timestamp => $crons ){

        if( in_array( $cron_name, array_keys( $crons ) ) ){
            return $timestamp - time();


    return false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.