[Code] Time based redirect

I'm looking for a way to redirect the page based on time. It works almost but it redirects to the wrong page, today is the second tuesday but it redirects to the url of the first tuesday.

This is the code I am using:

*****code attached*****

What is wrong with it?

  • Ash
    • WordPress Hacker

    Hello Menno

    Please try the following code:

    <?php
    
    // Content & SEO webinar //
    if ( strtotime('today') == strtotime('first tuesday of this month') || strtotime('today') == strtotime('third tuesday of this month')) {
    header('Location: https://www.men******a.com/ja/aanbieding-content-seo-trends-webinar');
    exit;
    // Website & Webshop Trends Webinar //
    } elseif ( strtotime('today') == strtotime('second tuesday of this month') || strtotime('today') == strtotime('fourth tuesday of this month')) {
    header('Location: https://www.men******a.com/ja/aanbieding-website-webshop-trends-webinar');
    exit;
    // Online psychologie & conversie Webinar //
    } elseif ( strtotime('today') == strtotime('first thursday of this month') || strtotime('today') == strtotime('third thursday of this month')) {
    header('Location: https://www.men******a.com/ja/aanbieding-online-psychologie-conversie-webinar');
    exit;
    // Facebook Ads webinar //
    } elseif ( strtotime('today') == strtotime('second thursday of this month') || strtotime('today') == strtotime('fourth thursday of this month')) {
    header('Location: https://www.men******a.com/ja/mwmfa');
    exit;
    // Geen webinar
    } else {
    header('Location: https://www.men******a.comaanbieding-verlopen');
    exit;
    }
    
    ?>

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.