mcmuney Posted April 3, 2007 Share Posted April 3, 2007 I'd like to use an if/then statement on a certain page making it work during certain times. For example, if time is between 6pm - 10am, then A else B, what code would I need for that? Thanks. Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/ Share on other sites More sharing options...
Lumio Posted April 3, 2007 Share Posted April 3, 2007 <?php if (A != B) { dosomething(); } ?> Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/#findComment-220384 Share on other sites More sharing options...
mcmuney Posted April 3, 2007 Author Share Posted April 3, 2007 I know the basic if/then statement, but I don't know how to specify the time.. if time is between 6pm and 10am, do A else do B. Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/#findComment-220393 Share on other sites More sharing options...
Lumio Posted April 3, 2007 Share Posted April 3, 2007 <?php $h = date('G'); if ($h <= 10 || $h >= 18) { //if $h is under or the same as 10 or $h is over or the same as 18 do... A(); }else { B(); } ?> Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/#findComment-220406 Share on other sites More sharing options...
mcmuney Posted April 5, 2007 Author Share Posted April 5, 2007 Hey thanks, this appears to be working; however, I have a concern that it may only be utilizing the server time, is it? Can you confirm? Because I need it to work with the time of the user and not the server time. Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/#findComment-221721 Share on other sites More sharing options...
AndyB Posted April 5, 2007 Share Posted April 5, 2007 php will use server time (that's where php executes). If you want user time, then only javascript can get that. Link to comment https://forums.phpfreaks.com/topic/45391-ifthen-with-time/#findComment-221728 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.