Results 1 to 7 of 7

Thread: Daylight saving

Hybrid View

  1. #1

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Daylight saving

    Whats the best way to adjust times to acount for daylight saving. Is there any built in functions or do I have to manually work it out?
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Daylight saving

    Usually the operating system takes care of this. However, you can use both the date() and localtime() functions to find otu whether or not daylight savings time is in effect.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: Daylight saving

    Problem is though the server is if the server is in the US and the time I'm after is british time then the server won't adjust for daylight saving at the right time.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  4. #4
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: Daylight saving

    i dont beleive there is a way to ask the client for the time. if they stated that they were (lets say) 4 hours difference, you could eassily do it:
    http://us3.php.net/localtime (there are examples in there)
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  5. #5

    Thread Starter
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349

    Re: Daylight saving

    Quote Originally Posted by ALL
    i dont beleive there is a way to ask the client for the time. if they stated that they were (lets say) 4 hours difference, you could eassily do it:
    http://us3.php.net/localtime (there are examples in there)
    No if I use localtime() it will adjust for daylight savings based on when the US implement it, because thats where the server is. I guess I'll just have to put up with that as I expect most my customers will have UK based servers, even though my demo server is US based .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Daylight saving

    Like the forum software, you could ask the user to specify their timezone offset and ask them whether they have daylight savings time in their country. You can also use gmdate() function to return the GMT time which will be calculated using the servers timezone offset.

    You can also use the date function to find the offsaet from GMT in seconds. Combined with the offset for the current locale (e.g GMT+2hours) you can calculate the timestamp for the client based on that:
    PHP Code:
    $server_gmtoffset = (int) date('Z');
    $local_offset 2//in hours

    $localtime time() - $server_gmtoffset - ($local_offset 60 60); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Daylight saving

    Use setlocale() and hope the locale is installed on the target server:
    PHP Code:
    <?php
    setlocale
    ("de-AT"); // Set locale to German, Austria
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width