how do you make a page only accessable after a certain time?

qwertyuiop12

New Member
Messages
17
Reaction score
0
Points
0
hi im making a site and i want to make a page to be only accesable after 3.15pm. if there cant be a way dont matter.

i use dreamweaver cs4
my file client is filezilla
 

garrettroyce

Community Support
Community Support
Messages
5,611
Reaction score
249
Points
63
You also need to consider when the page becomes inaccessible again. It's always after 3:15pm yesterday!

Using PHP:
Code:
if(intval(date('H')) >= 15 && intval(date('H')) < 24 || (intval(date('H')) > 15 || intval(date('i')) >= 15)) { // if the time is greater than 4pm or at least 15 minutes past the hour

// after 3:15 page

}
else {

// another page

}
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
Another thing to consider is when 15:15 actually is. It is that time for you/the time the server happens to be on, or is it specifically after 15:15 for each visitor to your site?
 

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
another way you can do it is this way

Code:
if(strtotime('now') >= strtotime('3:15 pm')){

}else{
echo 'I am sorry, you are not allowed to view this page.';
}

granted, I am not sure how well that will work or even if it will work.
 

Scoochi2

New Member
Messages
185
Reaction score
0
Points
0
another way you can do it is this way

Code:
if(strtotime('now') >= strtotime('3:15 pm')){

}else{
echo 'I am sorry, you are not allowed to view this page.';
}
granted, I am not sure how well that will work or even if it will work.
Not at all, for several reasons...
the best route to go down would be
PHP:
<?php
$page1 = 'pages/after315.html';
$page2 = 'pages/before315.html';

if ((date('G') > 15) || ((date('G') == 15) && (date('i') >= 15)))
require_once($page1);
else
require_once($page2);
?>
Simply put, that checks if the current server hour is after 15 (3pm), or if it is 15 AND the minutes have reached 15.
After that it will use the require() function to load a different page. Should it be the right time, it will load one page, else it will load a different one. Those pages were defined in variables are the start.

This will use the server time. Every day, page 2 will load from midnight until 15:15, which will then show page1 until midnight :D
 
Last edited:

qwertyuiop12

New Member
Messages
17
Reaction score
0
Points
0
thank u scoochi2 for your help. and also im trying to install mybb forum but im stuck.

heres what ive done.

1. downloaded th Upload file and uploaded them to my site
2. using filezilla chmodded the files
3. made a database called db and name came out as duffryc_db
whitch i will use in step 5
4.started installation
5. cant get passed step four after i type in all the details and click next it says error i typed in sumfin wrong.
 

Chris S

Retired
Messages
2,055
Reaction score
1
Points
38
Not at all, for several reasons...
the best route to go down would be
PHP:
<?php
$page1 = 'pages/after315.html';
$page2 = 'pages/before315.html';

if ((date('G') > 15) || ((date('G') == 15) && (date('i') >= 15)))
require_once($page1);
else
require_once($page2);
?>
Simply put, that checks if the current server hour is after 15 (3pm), or if it is 15 AND the minutes have reached 15.
After that it will use the require() function to load a different page. Should it be the right time, it will load one page, else it will load a different one. Those pages were defined in variables are the start.

This will use the server time. Every day, page 2 will load from midnight until 15:15, which will then show page1 until midnight :D

not to sound rude or anything...can you explain why that won't always work? I mean you said several reasons...and then just went on explaining your method and not backing up your claim.

So as a learning experience for me, what are the reasons that this won't work.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
thank u scoochi2 for your help. and also im trying to install mybb forum but im stuck.

heres what ive done.

1. downloaded th Upload file and uploaded them to my site
2. using filezilla chmodded the files
3. made a database called db and name came out as duffryc_db
whitch i will use in step 5
4.started installation
5. cant get passed step four after i type in all the details and click next it says error i typed in sumfin wrong.

Did you create a database user as well? A user needs to be created and linked to that database, and granted all available privileges.
 
Top