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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post

    Can you format php's date() to use a timezone?

    Hey

    I was wondering if it were possible to format php's date() function to display in a specific time zone, mine which is -07:00, and not the servers which is +02:00. Is this possible? I *thought* it was something like O-07:00 but O only displays ther servers timezone...any help is appreciated.
    Last edited by Bry Man; 06-30-2005 at 02:15 AM.
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    just find out what the servers time zone is and add or subtract to obtain the right figure?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    How would you go about doing that? I didnt think that you could subtract or add time to the servers time, thats what I thought that O -07:00 would do. Im using it as part of a user logging script that...logs users, and the time is kinda important. Im sorry but im not well versed in some areas of php, simple and complex as they may be. Could you perhaps provide an example please? Thanks for the reply though.
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #4
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    Try this:

    PHP Code:
    $hour_difference "7";

    $timeadjust = ($hour_difference 60 60);

    $local_timestamp date("l, d F Y h:i a",time() - $timeadjust);

    print (
    "$local_timestamp"); 

    your hour difference from the server is -7, which is why you are subtracting $timeadjust from time(), instead of adding it....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    California
    Posts
    511
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks for the help, that works great
    When traveling down the road of life, Try not to drag your face in the gravel.

  • #6
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,746
    Thanks
    18
    Thanked 155 Times in 146 Posts
    you're welcome...
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!


  •  

    Posting Permissions

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