[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 837
  • Last Modified:

PHP date_default_timezone_set scope

What is the scope of action on date_default_timezone_set in PHP?

I mean if I use:
function foo()
{
date_default_timezone_set('valid string'); /* where valid string is a valid date_default_timezone_set parameter */
echo (date('bla bla'));
}

after the use of foo() the dates will get back to normal/default time zone?
0
mychel_normandeau
Asked:
mychel_normandeau
1 Solution
 
hujiCommented:
There most be something else wrong with your code. I wrote this piece of code:

<?
echo date("l dS of F Y h:i:s A");
echo "<BR>";
date_default_timezone_set("Asia/Tokyo");
echo date("l dS of F Y h:i:s A");
echo "<BR>";
function foo()
{
  date_default_timezone_set("Europe/Paris");
  echo date("l dS of F Y h:i:s A");
  echo "<BR>";
}
foo();
echo date("l dS of F Y h:i:s A");
?>

And it returns the same value on the last two calls.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now