manutd4eva
Dec 31, 2005, 10:39 AM
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
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
Jan 3, 2006, 03:25 AM
Thanks I will try php or jsp
Thanks
LTheobald
Jan 3, 2006, 04:55 AM
Comparing the dates is the easy part. Using Javascript you can do something like below:
// 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:
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
Jan 3, 2006, 04:57 AM
Thanks
I have heard it is possible in mySQL is that true?
Thanks