Site icon Hip-Hop Website Design and Development

Execute code at the end of each quarter of year

I need to execute a script once every time we reach the end of a quarter (30th of March, 30th of June, 30th of September and 31st of December.

I’ve found wp_schedule_event on the documentation (https://codex.wordpress.org/Function_Reference/wp_schedule_event) and I generated the following snippet

// Custom Cron Recurrences
function custom_cron_job_recurrence( $schedules ) {
    $schedules['quarterly'] = array(
        'display' => __( 'quarterly', 'textdomain' ),
        'interval' => 7884000,
    );
    return $schedules;
}
add_filter( 'cron_schedules', 'custom_cron_job_recurrence' );

// Schedule Cron Job Event
function custom_cron_job() {
    if ( ! wp_next_scheduled( '' ) ) {
        wp_schedule_event( current_time( 'timestamp' ), 'quarterly', '' );
    }
}
add_action( 'wp', 'custom_cron_job' );

I’m not sure though, that the clock will start counting from the 1st of January.

Which is the correct way to do this?