Daylight Savings Time Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dredge

    Daylight Savings Time Question

    Hi, the server that hosts my PHP pages has its clock set to Greenwich
    Mean Time (GMT timezone 0). I need for my PHP scripts to have access
    to my local time which is Central Standard Time in the U.S. (CST
    timezone -6). Note: daylight savings time _is_ observed in my state. I
    have looked all over a PHP algorithm that would convert GMT to CST but
    have so far not been successful. Does anyone have such an algorithm
    lying around that they could post?

    Thanks in advance.

    Karl

  • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

    #2
    Re: Daylight Savings Time Question

    dredge wrote:
    Hi, the server that hosts my PHP pages has its clock set to Greenwich
    Mean Time (GMT timezone 0). I need for my PHP scripts to have access
    to my local time which is Central Standard Time in the U.S. (CST
    timezone -6).
    Just RTFM:

    php.net/date_default_ti mezone_set

    --
    ----------------------------------
    Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

    http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
    MSN:i_eat_s_p_a _m_for_breakfas t@hotmail.com
    Jabber:ivansanc hez@jabber.org ; ivansanchez@kde talk.net

    Comment

    • dredge

      #3
      Re: Daylight Savings Time Question

      On Mar 7, 9:14 am, Iván Sánchez Ortega <ivansanchez-...@rroba-
      escomposlinux.-.punto.-.orgwrote:
      dredge wrote:
      Hi, the server that hosts my PHP pages has its clock set to Greenwich
      Mean Time (GMT timezone 0). I need for my PHP scripts to have access
      to my local time which is Central Standard Time in the U.S. (CST
      timezone -6).
      >
      Just RTFM:
      >
      php.net/date_default_ti mezone_set
      >
      --
      ----------------------------------
      Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
      >

      MSN:i_eat_s_p_a _m_for_breakf.. .@hotmail.com
      Jabber:ivansanc ...@jabber.org ; ivansanc...@kde talk.net
      Woops, forgot to include that the server is running PHP 4.3.11 I
      believe the date_default_ti mezone_set function is only available in
      versions 5+

      Comment

      • =?ISO-8859-15?Q?Iv=E1n_S=E1nchez_Ortega?=

        #4
        Re: Daylight Savings Time Question

        dredge wrote:
        Woops, forgot to include that the server is running PHP 4.3.11 I
        believe the date_default_ti mezone_set function is only available in
        versions 5+
        You're right. I'd suggest you to upgrade to a PHP5 webserver.

        On the other hand, you can always use time() to get the current timestamp,
        at GMT+0, and manually substract 6 hours.

        You may also try the time/date functions that format dates - even if the
        internal clock is set at GMT (and it's a good idea to rely on GMT, believe
        me), if the server is already well configured, you don't have any need to
        manually set the timezone - the environment does that.

        By the way: please use GMT+0 (or unix timestamps) to keep dates on a
        database. If your country follows DST and you use the local date, you may
        run into lots of problems.

        --
        ----------------------------------
        Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-


        Proudly running Debian Linux with 2.6.17-1-amd64-k8 kernel, KDE3.5.3, and
        PHP 5.2.0-8 generating this signature.
        Uptime: 17:22:08 up 14 days, 22:23, 1 user, load average: 0.65, 0.41, 0.40

        Comment

        • Sanders Kaufman

          #5
          The GWB Bug - Bush Savings Time

          Iván Sánchez Ortega wrote:
          By the way: please use GMT+0 (or unix timestamps) to keep dates on a
          database. If your country follows DST and you use the local date, you may
          run into lots of problems.
          Not just "may" - it's a slam-dunk!

          Microsoft is announcing this week that you WILL run into
          problems on their systems... as are several other companies.

          In 2005, the Republican congress decided to mess with DST in
          order to trick some particularly foolish voters into believing
          that it will save energy dollars.

          As a result, for the next few months, most software written
          prior to 2005, and all hardware with DST algorithms in them, and
          which were built prior to 2005 will be messed up during these
          months.

          Comment

          • Gordon Burditt

            #6
            Re: The GWB Bug - Bush Savings Time

            >By the way: please use GMT+0 (or unix timestamps) to keep dates on a
            >database. If your country follows DST and you use the local date, you may
            >run into lots of problems.
            >
            >Not just "may" - it's a slam-dunk!
            Maybe, maybe not. It depends on what you're using the time stamps
            for. And *future* times are a problem, since your conversion from
            human local time units to UTC may turn out to be inaccurate if
            governments screw things up. I'll agree that having the OS clock
            in UTC is a good idea. (Let's see, we'll count heartbeats while 1
            minute goes by, starting at Sunday, 1:59:30 Mar 11, 2007. Wait!
            This guy's pulse rate is 3600! Yikes!)

            If I've got a clock that counts seconds and is expected to be accurate
            for the next 50 years, you'll need to fiddle with the display algorithm
            however many times governments screw with daylight savings time. This
            corresponds to the OS daylight savings time patches.

            If I'm a stay-at-home type of guy (don't change time zones much)
            if I've got an appointment calendar with a lunch appointment every
            Monday at noon, chances are much better the program will do what I
            mean if it stores that future appointment in local time. Chances are I
            mean the appointment is at noon, local time, regardless of whether
            it's a multiple of 7*24 hours since the last appointment. I might
            even mean noon, whatever local time zone I am in at the moment.
            This corresponds to the Microsoft Exchange Server and Outlook daylight
            savings time patches.

            If I do change time zones a lot, I probably want to record the time zone
            of the locality to which the appointment applies. Few users who need
            this ability will really use it to advantage until they get burned.
            And what, exactly, is the "locality" of a phone conference with members
            in several time zones?
            >Microsoft is announcing this week that you WILL run into
            >problems on their systems... as are several other companies.
            >
            >In 2005, the Republican congress decided to mess with DST in
            >order to trick some particularly foolish voters into believing
            >that it will save energy dollars.
            Has anyone come up with proof that this will save more energy than
            changing DST in the *other* direction? Most of the offered
            explanations (mostly by news media) involve DST actually changing
            the number of hours the sun is shining.

            Comment

            • Toby A Inkster

              #7
              Re: The GWB Bug - Bush Savings Time

              Gordon Burditt wrote:
              Let's see, we'll count heartbeats while 1 minute goes by, starting at
              Sunday, 1:59:30 Mar 11, 2007. Wait! This guy's pulse rate is 3600!
              Yikes!
              That would only happen in the autumn. In spring, the parient would be
              observed to have, say, 60 heartbeats over a period of 61 minutes.

              --
              Toby A Inkster BSc (Hons) ARCS
              Contact Me ~ http://tobyinkster.co.uk/contact
              Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

              * = I'm getting there!

              Comment

              Working...