It's 6:32 PM EST yet H is being returned as 22. I would expect it to be 18. PHP is version 5.3.9
What am I doing wrong here?
<?php
$time = date("H");
if( $time >= 06 && $time < 10 )
$img_name = 'sunrise.jpg';
if( $time >= 10 && $time < 17 )
$img_name = 'day.jpg';
if( $time >= 17 && $time < 19 )
$img_name = 'sunset.jpg';
if( $time >= 19 && $time < 06 )
$img_name = 'night.jpg';
?>
Two possible things:
Your server time could be off. Check the server it is hosted on to make sure it's not
Set a timezone. We can tell PHP which timezone to use by doing this:
date_default_timezone_set('America/Los_Angeles');
You can view a list of supported timezones here: http://php.net/manual/en/timezones.php