I have this piece of code
$timezone = 'America/New_York';
$now = new DateTime();
$now->setTimezone(new DateTimeZone('America/New_York'));
echo $now->format('Y-m-d h:i:s');
The above code works. But I want the $timezone
variable to replace 'America/New_York'.
This does not work...
$now->setTimezone(new DateTimeZone($timezone));
This also does not work...
$now->setTimezone(new DateTimeZone("$timezone"));
Please help me solve this problem, I would greatly appreciate it. Thanks.