Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Web Design (WordPress, Joomla, etc.) detect and redirect based on time

  • detect and redirect based on time

    Posted by Rik Wederstrandt on December 31, 2007 at 5:20 pm

    I have an index.html. This page redirects based on time of day. I would like it to redirect as follows
    6am-9am=morning.html
    9am-8pm=day.html
    8pm-6am=night.html
    the night and the day function fine but when it is time for the morning to redirect it defaults to the day.html. Have i done something wrong in this code. Any help would be greatly appreciated.

    function ampmRedirect(dayURL, nightURL) {
    var currentTime = new Date();
    var currentHour = currentTime.getHours();

    if ((currentHour < 6) || (currentHour > 20)) {
    window.location.href = “night.html”;
    } else if (currentHour >=9 || currentHour <17) {
    window.location.href = "day.html";
    } else {
    window.location.href = "morning.html";
    }
    }
    // -->

    BODY onLoad=”ampmRedirect(‘morning.html’,’day.html’,’eve.html’,’night.html’)””>

    Thanks Rik

    Rik Wederstrandt replied 18 years, 8 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy