selfproduction Posted March 8, 2007 Share Posted March 8, 2007 I'm trying to write a simple script that will display a message to guests between a certain time range, for example, 11 am to 12 pm. This is what I have so far, as I want it set into PST. I thought I'd be able to use an if/else to compare the times. But I'm not finding a way for it the $msgtimes to equal a time range. I may be going about this completely wrong, if someone could please point me in the right direction? <? $time_offset ="-3"; $adj = ($time_offset * 3600); $current = date("h:i", time() + $adj); $msgtimes = ; if ($current==$msgtime) { echo("message"); } else { echo("$current"); } ?> Link to comment https://forums.phpfreaks.com/topic/41741-trying-to-figure-this-out-oo/ Share on other sites More sharing options...
papaface Posted March 8, 2007 Share Posted March 8, 2007 Well 11 am is 11:00 and 12 pm is 12:00. Descriptive example: So if $current is more than or equal to "11:00" && (and) less than or equal to 12:00 - display the message. if ($current >= "11:00" && $current <= "12:00") { //show message. } Link to comment https://forums.phpfreaks.com/topic/41741-trying-to-figure-this-out-oo/#findComment-202368 Share on other sites More sharing options...
selfproduction Posted March 8, 2007 Author Share Posted March 8, 2007 Awesome, thanks. Link to comment https://forums.phpfreaks.com/topic/41741-trying-to-figure-this-out-oo/#findComment-202372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.