Reputation: 1
My website "skytamer.com" currently has 366 verions of the index.html page that I manually load each evening. The 366 versions are stored in the in the following directory:
www.skytamer.com/date/0101.html.
The 366 files, are denoted as i.e, 0101.html (January 1), 0601.html (June 1) etc., one for each day of the year.
I need a script that will automatically redirect the index.html page based on the computer's timestamp local month and day.
Example, the Earth keeps turning and 6 June comes around. The "index.html" page should then load "www.skytamer.com/date/0601.html" as the new "index.html" page.
Can this be done?
Upvotes: 0
Views: 433
Reputation: 11
The script:
function getPageToday() {
var today = new Date();
var day = String(today.getDate());
var month = String(today.getMonth() + 1);
if (day.length === 1) {
day = '0' + day;
}
if (month.length === 1) {
month = '0' + month;
}
var page = month + day + '.html';
return page;
}
Upvotes: 1
Reputation: 57729
<meta http-equiv="refresh" content="5;URL='http://example.com/'">
combined with a simple script that checks the date.
Keep in mind that timezones exist, so you might want grab the time from the server if you have server side scripting available.
Upvotes: 0