This topic is locked
[SOLVED]

 why can't i pass a variable into date_default_timezo

7/12/2011 11:46:55 PM
PHPRunner General questions
B
bertoruiz author

$myTimeZONE_var=$_SESSION['setting_timezone_session']; // I saved the TimeZone from a table into a Session and then saved it in this local variable
echo $myTimeZONE_var; //this shows exactly the folowwing: 'America/New_York'
date_default_timezone_set($myTimeZONEvar);

// I get the following error:

// Error type 8

// Error description date_default_timezone_set() [function.date-default-timezone-set]: Timezone ID ''America/New_York'' is invalid

B
bertoruiz author 7/13/2011



$myTimeZONE_var=$_SESSION['setting_timezone_session']; // I saved the TimeZone from a table into a Session and then saved it in this local variable
echo $myTimeZONE_var; //this shows exactly the folowwing: 'America/New_York'
date_default_timezone_set($myTimeZONEvar);

// I get the following error:

// Error type 8

// Error description date_default_timezone_set() [function.date-default-timezone-set]: Timezone ID ''America/New_York'' is invalid


I figured it out...I was passing an additional set of qoutes around the string into the date_default_timezone_set() function. This is wrong as qoutes are implicitly applied when passing a variable into the function. I should have just passed America/New_York into the variable instead of passing 'America/New_York'.