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"; } ?> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted October 23, 2009 Share Posted October 23, 2009 strtotime Quote Link to comment 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);?> Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.