Hyphen Posted September 29, 2008 Share Posted September 29, 2008 I'm fairly new with PHP and need a little help. I want to be able to display "x" if (by server time) it is 6pm through midnight, but display "y" at all other times. How is this executed? Link to comment https://forums.phpfreaks.com/topic/126225-executing-based-on-server-time/ Share on other sites More sharing options...
aeonsky Posted September 29, 2008 Share Posted September 29, 2008 Think this should do it: <?PHP if (date("G") >= 0 && date("G") < 18) echo "y"; else echo "x"; ?> And I'm pretty sure the time is already set to server time. Link to comment https://forums.phpfreaks.com/topic/126225-executing-based-on-server-time/#findComment-652753 Share on other sites More sharing options...
ratcateme Posted September 29, 2008 Share Posted September 29, 2008 $hour = date("G"); if($hour < 18){ echo "y"; }else{ echo "x"; } EDIT: beaten to it Scott. Link to comment https://forums.phpfreaks.com/topic/126225-executing-based-on-server-time/#findComment-652754 Share on other sites More sharing options...
aeonsky Posted September 29, 2008 Share Posted September 29, 2008 Haha, just realized that the >= 0 part wasn't necessary. XD Link to comment https://forums.phpfreaks.com/topic/126225-executing-based-on-server-time/#findComment-652756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.