Ask Experts Questions for FREE Help !
Ask
    manutd4eva's Avatar
    manutd4eva Posts: 209, Reputation: 14
    Full Member
     
    #1

    Dec 31, 2005, 10:39 AM
    Date and time script
    Does anyone know a script where I program in the dates and times and from say 8th January from 5.15 until 7.30 it takes you too page2 and after that it carries on taking you to the normal page then on the next date it does the same again so say the 12th from 8am-8.45.

    Thanks
    LTheobald's Avatar
    LTheobald Posts: 1,051, Reputation: 127
    Ultra Member
     
    #2

    Jan 3, 2006, 03:09 AM
    It can be done but can you answer one question first:

    Are you using a scripting language such as ASP, PHP or JSP (will make things a LOT easier). If you don't know what I'm on about the answer is no.
    manutd4eva's Avatar
    manutd4eva Posts: 209, Reputation: 14
    Full Member
     
    #3

    Jan 3, 2006, 03:25 AM
    Thanks I will try php or jsp

    Thanks
    LTheobald's Avatar
    LTheobald Posts: 1,051, Reputation: 127
    Ultra Member
     
    #4

    Jan 3, 2006, 04:55 AM
    Comparing the dates is the easy part. Using Javascript you can do something like below:

    Code:
    // Get the current date
    var today = new Date();
    
    // Set the date we want to compare (year,month,day,hours,mins,secs)
    // Note the month starts at 0, not 1.  So 0 = Jan, 1 = Feb, ...,  11 = Dec
    var compare = new Date(2006,00,01,09,00,00)
    
    // Compare the dates
    if (today > compare) {
        alert("COMPARE IN PAST");
    } else if (today < compare) {
        alert("COMPARE IN FUTURE");
    } else {
        alert("EQUAL");
    }
    </script>
    You could edit that to go into a function that takes a date and returns -1, 0 or 1 depending on the result.

    Throwing the user to another page is also simple and you can just use:

    Code:
    window.location = 'new location';
    The thing that is not easy in Javascript that you want is to have the ability to set what dates and times you want to redirect on. Doing this in Javascript would mean that you would need to have variables containing the dates and times you want to switch at. This is messy and would involve having to open and upload the javascript file each time you want to change a date/time.

    The solution here would be to use a database to store the switch dates and times. That way you could check the DB for a row corresponding to the current date. If the current date has a row in the DB, get the time for the DB. If the time from the DB is before the current time, go to page A. If it's on or after the current time, go to page B. This is where something like PHP comes in.

    I'll write you a PHP script to illustate what I mean. Just give me an hour or two to get round to it.
    manutd4eva's Avatar
    manutd4eva Posts: 209, Reputation: 14
    Full Member
     
    #5

    Jan 3, 2006, 04:57 AM
    Thanks
    I have heard it is possible in mySQL is that true?
    Thanks

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Date & time [ 3 Answers ]

::) How can you find out when a computer was last started and shut down.

To-date total based on current date [ 1 Answers ]

:confused: I am trying to create a forumula that will give a cumulative or "to-date" total that will exclude future months from the total. i.e. ithe point in time is August and I need to show a to-date number Through August only even though September and October are included in The...

F-1 to H-1, what's the start date of H-1? Should be approval date or visa issue day? [ 3 Answers ]

As I mention before, I changed from F-1 to H-1 last year. I got my H-1 status in Feb 2004, but I went to my home country to get the H-1 visa stamp in August 2004. So I would like to know for counting my H-1 status, is it the date that USCIS (the Immigration) approved (which is Feb 1st), or the...

Date and time problems Win 98 [ 3 Answers ]

Hai everybody, Every time when I start my computer, the time and date are resetted back to 1999. I find this rather inconvenient so can anybody help me with a solution. I still use win 98 and on the cd there is also no time-date file as far as I know. I hope somebody can help me. Bye Boud


View more questions Search