DaveLinger Posted November 15, 2006 Share Posted November 15, 2006 so my dad wants me to make his website so that if someone goes to it during daylight hours, it shows a daytime photo of the building. At night, it shows the night photo. I figure this can be done with a simple "if" statement, but I don't know how to work with PHP time formats! Link to comment https://forums.phpfreaks.com/topic/27302-if-current-time-is-between-7am-and-5pm-do-this-else-do-this/ Share on other sites More sharing options...
btherl Posted November 15, 2006 Share Posted November 15, 2006 date('G') will give you the current hour in 24 hour format. so..[code=php:0]$hour = date('G');if ($hour >= 7 && $hour < 17) { # daytime} else { # nighttime}[/code] Link to comment https://forums.phpfreaks.com/topic/27302-if-current-time-is-between-7am-and-5pm-do-this-else-do-this/#findComment-124846 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.