making gmdate output equal date output

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

    making gmdate output equal date output

    gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am.
    How do I add to the second parameter of the date function to make it
    always return that same date, regardless of the time zone?
    Intuitively, it seems like date('F j, Y, g:i a',0 - date('Z')) should
    do it, but on my system, that's an hour off.

    Here's some sample code:

    <?
    echo gmdate('F j, Y, g:i a',0).'<br />';
    echo date('F j, Y, g:i a',0 - date('Z')).'<br />';
    echo date('F j, Y, g:i a',0 - date('Z') + 60*60);
    ?>

    And here's the output on my system:

    January 1, 1970, 12:00 am
    December 31, 1969, 11:00 pm
    January 1, 1970, 12:00 am

    Will the last echo always return the same thing as the first echo,
    regardless of the time zone? If so, why? It seems that the second one
    is the one that should do it - not the first one.

  • yawnmoth

    #2
    Re: making gmdate output equal date output


    yawnmoth wrote:[color=blue]
    > gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am.
    > How do I add to the second parameter of the date function to make it
    > always return that same date, regardless of the time zone?
    > <snip>[/color]

    Never mind - I figured the answer out, myself. I need to correct for
    daylight savings time.

    date('F j, Y, g:i a',0 - date('Z') + 60*60*date('I') ) does it.

    Comment

    • John McClumpha

      #3
      Re: making gmdate output equal date output

      yawnmoth wrote:[color=blue]
      > Will the last echo always return the same thing as the first echo,
      > regardless of the time zone? If so, why? It seems that the second one
      > is the one that should do it - not the first one.[/color]

      erm... daylight savings perhaps?

      Comment

      Working...