[PHP-DEV] date('r') on windows gets wrong timezone From: Chuck Hagenbuch (chuck <email protected>)
Date: 12/04/00

On Windows (2000 Pro), the 'r' argument to date() (to get an RFC822 compliant
date) gets the wrong sign for the timezone offset - I'm in Eastern Standard
Time, which should be -0500, but for some reason it comes up with +0500. I
looked at ext/standard/datetime.c, and there's a line there to choose the + or -
, but I don't know enough about the underlying code to fix it.

Here's a script that will show the problem - run on unix the two times match,
on windows the signs for the tz offset is off.

<?php

function gm_offset () {
    $date = date('H');
    $gmdate = gmdate('H');
    /* Adjust for wrap-around, the difference can't be more than 12 hours.
     * AFAIK, -1200 is invalid, the correct one is +1200 (ie: at New Zealand).
     *
     * CHANGED Oct 18 2000 (Submitted by <demian <email protected>>) to handle
     * New Zealand daylight savings time.
     */
    if ($gmdate + 13 < $date) {
        $gmdate += 24;
    } else if ($date + 11 <= $gmdate) {
        $date += 24;
    }
    $offset = $date - $gmdate;
    if ($offset >= 0) {
        return sprintf("+%02d", $offset) . "00";
    } else {
        return sprintf("-%02d", -$offset) . "00";
    }
}

echo date('r');

echo '<hr>';

echo date('D, d M Y H:i:s ') . gm_offset() . ' (' . strftime('%Z') . ')';

?>

-chuck

--
Charles Hagenbuch, <chuck <email protected>>
"If you can't stand the heat, get out of the chicken!" - Baby Blues

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>