Forum Moderators: coopster

Message Too Old, No Replies

Can I use PHP time to swith my ads on or off?

         

andrewshim

3:43 pm on Apr 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a page that calls my Adsense codes from a script folder using the "include" statement. I'd like to switch off one particular Adsense block from midnight to 8am (US time).

Is this possible using PHP? If it's possible, do I refer to my server time? Any examples would be most helpful.

jatar_k

3:52 pm on Apr 24, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> Is this possible using PHP?

absolutely

>> do I refer to my server time?

yes, keep an eye because your server may be in a different timezone

something like so maybe (test it first because I didn't)

$hour = date('G');
if ($hour >= 0 && $hour < 8) {
// ad code here
}

a quick one but I think it's right

reference
[php.net...]

londrum

9:05 pm on Apr 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



bear in mind that it won't be foolproof... as the user might still have the old page in his cache. you might want to make it uncachable.

andrewshim

3:11 am on Apr 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks jatar... seems to be okay. Yay!