I have the following code…
$stored_date = date_format(date_create('now'), 'Y-m-d H:i:s');
echo 'Stored date: ' . $stored_date . "<br/>";
$user_timezone = 'Australia/Brisbane';
I would like to convert $stored_date (which was created based on the server’s timezone to a date or a string representation of the date based on $user_timezone.
I would like to do that using procedural PHP code rather than OO code.
I have tried..
date_create($stored_date, timezone_open($user_timezone));
but that doesn’t seem to to give a correct answer.
if $stored_date is '2011-11-15 23:45:35' with the server’s timezone being ‘America/Toronto’ the result I’m getting is the same ‘2011-11-15 23:45:35’.
however, date_create('now', timezone_open($user_timezone)); seems to work and give the correct date as per the $user_timezone.
any ideas on what i’m doing wrong?
thanks
you should try this. this had been worked for me.
hope this will help you.
here is the list of PHP timezones: