SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    System Time different from PHP getdate()

    Are there any settings to be done in Apache .conf file to set time zone or something?

    I'd just realized the getdate() function return from PHP is different from my system time. How can that be when I'm setting up apache as a local server?
    Need some advise here. Thanks

  2. #2
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is returned by your PHP script and what is the date/time in your local system?

    I am using WAMP server on my windows machine. I never changed any setting of Apache. I am getting the identical time from the test php script that I used.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm....that was my home pc. now at work, it prompts me a message
    Strict Standards</b>: getdate() [<a href='function.getdate'>function.getdate</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in ...
    so i wrote in
    date_default_timezone_set('Asia/Singapore');
    and it seems to work fine here. going to try again when i get home tonite.

    heres the full code:
    <?php
    date_default_timezone_set('Asia/Singapore');
    echo "<pre>";
    print_r(getdate());
    echo "</pre>";
    ?>

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    resting,

    As you've discovered, that's a PHP setting (to allow PHP to use a different timezone). Therefore, I've moved this to the PHP forum.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Addict
    Join Date
    Jul 2009
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup its the php setting. and the above code works for my home pc too


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •