Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Is there a way for particular pages to loadup depending on the time of day?
Old 12-02-2007, 09:28 AM Is there a way for particular pages to loadup depending on the time of day?
Skilled Talker

Posts: 97
Trades: 0
Is there a way for particular pages to loadup depending on the time of day?

Much thanks
keithkiss is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-02-2007, 09:48 AM Re: Is there a way for particular pages to loadup depending on the time of day?
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
What exactly do you mean by "loadup"?

If you mean show up you could use the date function, for example.

PHP Code:
$date date("Gis"); // Lets say this brings back 151005, where 15 (G) is the Hour, 10 (i) is the minutes and 05 (s) is the seconds.
if($date >= 150000 and $date <= 180000){ // If the time is before 15:00:00 (3PM) and  16:00:00 (6PM) show the site.

} else { // Show an error message.

__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 12-02-2007 at 09:54 AM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 12-02-2007, 11:05 AM Re: Is there a way for particular pages to loadup depending on the time of day?
Skilled Talker

Posts: 97
Trades: 0
sorry what I mean was for example....

index.php will have includes that say

between 2 and 3 am load 2.php
between 3 and 4 am load 3.php

Again much thanks, php is really cool... I want get down to some more serious studying
keithkiss is offline
Reply With Quote
View Public Profile
 
Old 12-02-2007, 01:06 PM Re: Is there a way for particular pages to loadup depending on the time of day?
barriehie's Avatar
Junior Talker

Posts: 3
Name: Barrie
Location: Las Vegas, NV
Trades: 0
Okay, after 1/2 cup of coffee something like this should work:

PHP Code:
<?php
 
// This is getting the time off of the server and the 0 <= hours <= 23.
 
$filesuffix date("H");
settype($filesuffix"string");
$file2load $filesuffix."php";
include 
'$file2load';
exit();
 
?>
Hope this helps,
Barrie


Quote:
Originally Posted by keithkiss View Post
sorry what I mean was for example....

index.php will have includes that say

between 2 and 3 am load 2.php
between 3 and 4 am load 3.php

Again much thanks, php is really cool... I want get down to some more serious studying

Last edited by barriehie; 12-02-2007 at 01:08 PM..
barriehie is offline
Reply With Quote
View Public Profile
 
Old 12-02-2007, 03:07 PM Re: Is there a way for particular pages to loadup depending on the time of day?
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
You might want something like this

PHP Code:
<?php

/* get the hour of the day in 24 hour format */
$displaydate date('G');

/* dispaly page between 1 and 2 pm */
if ($displaydate >= 13 and <= 14) {
    include(
'13.php');
}
/* dispaly page between 2 and 3 pm */
elseif ($displaydate >= 14 and <= 15) {
    include(
'14.php);
}
elseif (and  so on) {
}
else {
    include('
default.php')
}
?>
joder is offline
Reply With Quote
View Public Profile
 
Old 12-03-2007, 01:44 AM Re: Is there a way for particular pages to loadup depending on the time of day?
Skilled Talker

Posts: 97
Trades: 0
so is there a variable for displaytime?

The flow of the script is perfect so far....Im getting the idea slowly

Much thanks

Do you know any good PHP documentation for noobs like me?
(Like how to use what variables exist and how to use them)

Last edited by keithkiss; 12-03-2007 at 01:46 AM..
keithkiss is offline
Reply With Quote
View Public Profile
 
Old 12-03-2007, 10:20 AM Re: Is there a way for particular pages to loadup depending on the time of day?
joder's Avatar
Flipotron

Posts: 6,442
Name: James
Location: In the ocean.
Trades: 0
At the beginning $displaydate is declared as the hour of the day in 24 hour format:
$displaydate = date('G');

There are tons of books. The best documentation is on the php web site
http://www.php.net/docs.php

For me, I have not found one book. None of them are complete. But I think the Oreilly has some very good books.
Learning PHP5
Learning PHP and MySQL
PHP Cookbook


joder is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Is there a way for particular pages to loadup depending on the time of day?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29465 seconds with 12 queries