PHP date_default_timezone_set scope

Posted on 2007-07-20
Last Modified: 2012-05-05
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?
Question by:mychel_normandeau
    1 Comment
    LVL 14

    Accepted Solution

    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>";
    echo date("l dS of F Y h:i:s A");
    echo "<BR>";
    function foo()
      echo date("l dS of F Y h:i:s A");
      echo "<BR>";
    echo date("l dS of F Y h:i:s A");

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    A colleague recently asked me about how to give his client a small part of the web site that could be completely under the client's control.  Since I have done this sort of thing before to add emergency banners to a web site, I decided I would creat…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now