Variable $now won't display unless it is dumped. It's populated. It doesn't display the "now is empty" string at all. It won't display what is inside $now unless it is var_dump or var_exported.
$ipData = json_decode( $ttt, true);
$now="";
if ($ipData['timezone']) {
$tz = new DateTimeZone( $ipData['timezone']);
$now = new DateTime( 'now', $tz); // DateTime object corellated to user's timezone
} else {
// we can't determine a timezone - do something else...
}
if($now==""){echo "now is empty";}
echo "<br />
<br />
".$now->timezone.$now->date;
var_dump($now);
}
if(isset($now)){echo "It is set.";} It's definitely set, though I set it to "" before I actually called it, so no matter what it was initialized.
Even removing the $now=""; shows that it is initialized. var_dump($now); echos this:
object(DateTime)#30 (3) { ["date"]=> string(19) "2013-05-06 22:52:29" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" } After var_dump $now->timezone is equal to America/New_York