Question: The code below is meant to show my visitors something like "Good Morning, Today is ------ and the time is -----"

But I keep getting "Welcome" instead of the main greetings. Why is this?

```
<?php
$hour = date ("G");
$minute = date ("i");
$second = date ("s");
$msg = " Today is " . date ("l, M. d, Y.") . " And the time is " . date ("g:i a");

if ($hour = 00 && $hour <= 9 && $minute <= 59 && $second <= 59) 
{ $greet = "Good Morning,"; }

else {

if ($hour >= 10 && $hour <= 11 && $minute <= 59 && $second <= 59)
{ $greet = "Good Day,"; }

if ($hour >= 12 && $hour <= 15 && $minute <= 59 && $second <= 59)
{ $greet = "Good Afternoon,"; }

if ($hour >= 16 && $hour <= 23 && $minute <= 59 && $second <= 59)
{ $greet = "Good Evening,"; }

else { $greet = "Welcome,"; }
 }
echo $greet.$msg;
?>

```

Any idea on how to get this done? 

How do I get timezones of my visitors automatically using php. My server's default timezone is Lagos/Africa. I want the code above to show my visitors their local time and date.

Answer: 
Your problem is here 

```
 if ($hour = 00 && $hour <= 9 && $minute <= 59 && $second <= 59) 

```

this way you assign 00 to $hour and all the other condition fails 

you need 

```
if ($hour == 0 && $hour <= 9 && $minute <= 59 && $second <= 59) 

```

solved the if problem there are others 

You should keep in mind that php date() function return a string 
there are several way for solve your code problem these are just some suggestion  

so you should commpare string (not number) or convert the string in number for commparision using a proper cast

Looking to your if you can also avoid the check for minute ( are always <= 59) this mean that you code could be 

```
  <?php 

      $hour = date("G"); 
      $minute = date("i"); 
      $second = date("s"); 
      $msg = " Today is " . date("l, M. d, Y.") . " And the time is " . date("g:i a"); 

      if ( (int)$hour == 0 && (int)$hour <= 9 ) { 
          $greet = "Good Morning,"; 
      } else if ( (int)$hour >= 10 && (int)$hour <= 11 ) { 
          $greet = "Good Day,"; 
      } else if ( (int)$hour >= 12 && (int)$hour <= 15 ) { 
          $greet = "Good Afternoon,"; 
      } else if ( (int)$hour >= 16 && (int)$hour <= 23 ) { 
          $greet = "Good Evening,"; 
      } else { 
          $greet = "Welcome,"; 
      }

      echo $greet.$msg;
  ?>

```
try this....

```
<?php
    $hour = date ("G");
    $minute = date ("i");
    $second = date ("s");
    $msg = " Today is " . date ("l, M. d, Y.") . " And the time is " . date ("g:i a");

    if ($hour == 00 && $hour <= 9 && $minute <= 59 && $second <= 59){
        $greet = "Good Morning,";
        }else if ($hour >= 10 && $hour <= 11 && $minute <= 59 && $second <= 59){
            $greet = "Good Day,";
            }else if ($hour >= 12 && $hour <= 15 && $minute <= 59 && $second <= 59){
                $greet = "Good Afternoon,";
            }else if ($hour >= 16 && $hour <= 23 && $minute <= 59 && $second <= 59){
                $greet = "Good Evening,";
            }else {
                $greet = "Welcome,";
            }

        }

    echo $greet.$msg;
?>

```

I recommend you read some tuts