matafy Posted October 23, 2009 Share Posted October 23, 2009 I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorado time if my server is in California and it would be 8:00am. I tried to echo the image below, but it's not working. <?php $hours_offset = -1; // Server time offset function currentImage(){ global $hours_offset; $hour = date("H",(time()-(3600*$hours_offset))); $imagePath = "img/"; if (date(H) < 09 || date(H) > 21) { return $imagePath."".date(D)."/".$hour.".png"; } ?> Link to comment https://forums.phpfreaks.com/topic/178686-need-help-php-timing-issues/ Share on other sites More sharing options...
Andy-H Posted October 23, 2009 Share Posted October 23, 2009 strtotime Link to comment https://forums.phpfreaks.com/topic/178686-need-help-php-timing-issues/#findComment-942552 Share on other sites More sharing options...
matafy Posted October 23, 2009 Author Share Posted October 23, 2009 Would this work instead? This is what I came up with. <?php $hours_offset = -1; // Server time offset function currentImage($hours_offset){ $day = date(D) $hour = date("H",(time()-(3600*$hours_offset))); $imagePath = "img/"; if ($hour < '09' || $hour > '21') { return $imagePath."".$day."/".$hour.".png"; } ?> <?php echo currentImage($hours_offset);?> Link to comment https://forums.phpfreaks.com/topic/178686-need-help-php-timing-issues/#findComment-942558 Share on other sites More sharing options...
Andy-H Posted October 23, 2009 Share Posted October 23, 2009 After a little googling I came up with this: <?php date_default_timezone_set('America/Denver'); echo date_default_timezone_get() . '<br ><br >'; echo date("H:i:s"); ?> Output: America/Denver 23:21:06 A touch out (+4 maybe 5 seconds) but shouldn't really matter? Link to comment https://forums.phpfreaks.com/topic/178686-need-help-php-timing-issues/#findComment-942604 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.