Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts

    PHP time 1 hour fast.

    when i use a standard PHP date statement
    PHP Code:
    $date date('l dS \of F Y h:i:s A'); 
    echo 
    "$date"
    the time is 1 hour fast of my local time.
    any ideas on how to make the h (hour) -- (minus)
    solved.
    PHP Code:
    $date date('l dS \of F Y h:i:s A', -time(3600)); 
    Last edited by rafiki; 02-19-2008 at 04:37 PM.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,091
    Thanks
    2
    Thanked 322 Times in 314 Posts
    The date() function adjusts for the local time on the server, including any daylight saving time shifts. If you want to make your server appear to be in a different time zone than what it really is, either set the date.timezone parameter in a php.ini or .htaccess file or use the date_default_timezone_set() function in your script -

    http://www.php.net/manual/en/ref.dat....date.timezone
    http://www.php.net/manual/en/functio...mezone-set.php
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    problem im using 4.4.7
    my host does offer 5.2.3, but not sure how to activate it.

  • #4
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    PHP Code:
    $date date('l dS \of F Y h:i:s A'time() - 3600); 

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    That's a classic case of 'fixing the symptom, not the problem' which is a bad thing.

  • #6
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Solution Two: Turn back the clock on your server...

    We should make a spam-only thread so aedrin can just post in there all day to crank up his post count, instead of saying things that are completely unhelpful.

  • #7
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Aedrin is technically correct, that solution does only fix the symptom but not the cause. Which is something valid to point out in case the OP doesn't realize it.

    However Aedrin you could have phrased it more diplomatically or suggested an alternate solution that fixes the root cause.

    Andrew Johnson, while he could have been more helpful, his point is still valid. Insinuating that all he does is spam the forum is just as wrong as what he did.

    Everyone just play nice.
    OracleGuy

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by rafiki View Post
    when i use a standard PHP date statement
    PHP Code:
    $date date('l dS \of F Y h:i:s A'); 
    echo 
    "$date"
    the time is 1 hour fast of my local time.
    any ideas on how to make the h (hour) -- (minus)
    solved.
    PHP Code:
    $date date('l dS \of F Y h:i:s A', -time(3600)); 
    andy you didn't just post what i did now whos spamming?
    i just want to say if its aedrin, then its you aswell.

  • #9
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by oracleguy View Post
    However Aedrin you could have phrased it more diplomatically or suggested an alternate solution that fixes the root cause.
    Quote Originally Posted by Andrew Johnson View Post
    We should make a spam-only thread so aedrin can just post in there all day to crank up his post count, instead of saying things that are completely unhelpful.
    I will only post what I find helpful/beneficial. This doesn't mean it has to be helpful for everyone (except perhaps the OP).

    I didn't think my comment was offensive or too forward, I was pointing out a problem that a lot of people don't consider. It was on topic and there was value in it. Hence it can't be considered spam. And there is little point in insinuating topic count is my reason to post. I post here to improve my knowledge of PHP by looking at problems I don't come across in my domain and figuring out solutions without being the designer of the code.

    Solution Two: Turn back the clock on your server...
    This has the same issue. Fixing the symptom, not the problem.

    Symptom: The time shows up an hour off.
    Problem: The server is configured to display the wrong timezone.

    These should've been known at the time the thread was started (basic time keeping concepts).

    It's easy to determine that the solution needed is to figure out how to choose a right/better timezone.

    For instance, choosing a different timezone at the top of your main script. PHP has multiple ways of choosing this. Whether the version of PHP that is used supports these methods is something the OP can find out for himself. Much better than us, in any case (since we do not have access to the server).

    A lot of my response is based on the OP's personal input. If someone just states the original problem they're having and asks for the solution, I have little reason to give more than 1-2 lines of response. If someone figured out the problem and need help with the solution, and show what they have come up with so far, then I'm willing to put some coding effort into it.


  •  

    Posting Permissions

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