How to make Apache aware of Daylight Saving Time?

Discussion in 'Tech Talk' started by gwalchmai, Sep 22, 2005.

  1. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
    I'm running Apache 2 on a Win2000 machine. Works fine, but Apache doesn't seem to be DST aware. All the log entries are an hour ahead, and I have a little PHP app that sends an email, and its timestamp is off by an hour. I can't seem to find the directive to make it work.
     
  2. Dandapani

    Dandapani

    Messages:
    8,216
    Likes Received:
    13
    Joined:
    Mar 24, 2004
    Location:
    Gulf side Florida
    Does Windblow$ have concept about TZ variable? I'm a unix/linux guy. TZ should indicate DST is a factory in your timezone.
     

  3. Dandapani

    Dandapani

    Messages:
    8,216
    Likes Received:
    13
    Joined:
    Mar 24, 2004
    Location:
    Gulf side Florida
    Do you have the Settings->Control Panel->Date/Time->Time Zone box checked for Automatically adjust Clock for Daylight Savings Time?
     
  4. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
    The OS is aware of DST. All its filestamps and functions have the correct time. It's just the Apache stuff that's off.
     
  5. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
    i.e., the web server doesn't seem to be picking up the correct time zone/DST information from the OS.
     
  6. HerrGlock

    HerrGlock Scouts Out CLM

    Messages:
    23,804
    Likes Received:
    264
    Joined:
    Dec 28, 2000
    You may want to stop and start apache and see if it picks it up. Apache SHOULD pick it up from the OS. Mine do and the log files are correct after the change.

    DanH
     
  7. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
    Good thought, but restarting apache, or rebooting the OS, doesn't seem to change it.
     
  8. HerrGlock

    HerrGlock Scouts Out CLM

    Messages:
    23,804
    Likes Received:
    264
    Joined:
    Dec 28, 2000
    Does the user that you have Apache running as have the time zone set correctly?

    NOT you, probably NOT the administrator, but the user Apache runs as.

    DanH
     
  9. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
  10. HerrGlock

    HerrGlock Scouts Out CLM

    Messages:
    23,804
    Likes Received:
    264
    Joined:
    Dec 28, 2000
    You're really looking to come up with an impossible one,aren't you? ;f

    See if there's anything in here that'll help

    Module mod_log_config
    This module is contained in the mod_log_config.c file, and is compiled in by default in Apache 1.2. mod_log_config replaces mod_log_common in Apache 1.2. Prior to version 1.2, mod_log_config was an optional module. It provides for logging of the requests made to the server, using the Common Log Format or a user-specified format.
    Summary
    Three directives are provided by this module: TransferLog to create a log file, LogFormat to set a custom format, and CustomLog to define a log file and format in one go. The TransferLog and CustomLog directives can be used multiple times in each server to cause each request to be logged to multiple files.

    Compatibility notes

    * This module is based on mod_log_config distributed with previous Apache releases, now updated to handle multiple logs. There is now no need to re-configure Apache to use configuration log formats.
    * The module also implements the CookieLog directive, used to log user-tracking information created by mod_usertrack. The use of CookieLog is deprecated, and a CustomLog should be defined to log user-tracking information instead.

    Log File Formats
    Unless told otherwise with LogFormat the log files created by TransferLog will be in standard "Common Log Format" (CLF). The contents of each line in a CLF file are explained below. Alternatively, the log file can be customized (and if multiple log files are used, each can have a different format). Custom formats are set with LogFormat and CustomLog.
    Common Log Format
    The Common Log Format (CLF) file contains a separate line for each request. A line is composed of several tokens separated by spaces:

    host ident authuser date request status bytes

    If a token does not have a value then it is represented by a hyphen (-). The meanings and values of these tokens are as follows:

    host
    The fully-qualified domain name of the client, or its IP number if the name is not available.
    ident
    If IdentityCheck is enabled and the client machine runs identd, then this is the identity information reported by the client.
    authuser
    If the request was for an password protected document, then this is the userid used in the request.
    date
    The date and time of the request, in the following format:

    date = [day/month/year:hour:minute:second zone]
    day = 2*digit
    month = 3*letter
    year = 4*digit
    hour = 2*digit
    minute = 2*digit
    second = 2*digit
    zone = (`+' | `-') 4*digit

    request
    The request line from the client, enclosed in double quotes (").
    status
    The three digit status code returned to the client.
    bytes
    The number of bytes in the object returned to the client, not including any headers.

    Custom Log Formats
    The format argument to the LogFormat and CustomLog is a string. This string is logged to the log file for each request. It can contain literal characters copied into the log files, and `%' directives which are replaced in the log file by the values as follows:

    %...b: Bytes sent, excluding HTTP headers.
    %...f: Filename
    %...{FOOBAR}e: The contents of the environment variable FOOBAR
    %...h: Remote host
    %...{Foobar}i: The contents of Foobar: header line(s) in the request
    sent to the server.
    %...l: Remote logname (from identd, if supplied)
    %...{Foobar}n: The contents of note "Foobar" from another module.
    %...{Foobar}o: The contents of Foobar: header line(s) in the reply.
    %...p: The port the request was served to
    %...P: The process ID of the child that serviced the request.
    %...r: First line of request
    %...s: Status. For requests that got internally redirected, this
    is status of the *original* request --- %...>s for the last.
    %...t: Time, in common log format time format
    %...{format}t: The time, in the form given by format, which should
    be in strftime(3) format.
    %...T: The time taken to serve the request, in seconds.
    %...u: Remote user (from auth; may be bogus if return status (%s) is 401)
    %...U: The URL path requested.
    %...v: The name of the server (i.e. which virtual host?)

    The `...' can be nothing at all (e.g. "%h %u %r %s %b"), or it can indicate conditions for inclusion of the item (which will cause it to be replaced with `-' if the condition is not met). Note that there is no escaping performed on the strings from %r, %...i and %...o; some with long memories may remember that I thought this was a bad idea, once upon a time, and I'm still not comfortable with it, but it is difficult to see how to `do the right thing' with all of `%..i', unless we URL-escape everything and break with CLF.

    The forms of condition are a list of HTTP status codes, which may or may not be preceded by `!'. Thus, `%400,501{User-agent}i' logs User-agent: on 400 errors and 501 errors (Bad Request, Not Implemented) only; `%!200,304,302{Referer}i' logs Referer: on all requests which did not return some sort of normal status.

    Note that the common log format is defined by the string "%h %l %u %t \"%r\" %s %b", which can be used as the basis for extending for format if desired (e.g. to add extra fields at the end). NCSA's extended/combined log format would be "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"".
     
  11. David_G17

    David_G17 /\/\/\/\/\/\/\/

    Messages:
    2,046
    Likes Received:
    7
    Joined:
    Oct 7, 2002
    edited to add: nevermind, misread the problem.
     
  12. aspartz

    aspartz

    Messages:
    3,281
    Likes Received:
    133
    Joined:
    Oct 19, 2000
    Location:
    Sandstone, MN 55072
    Are you sure the time offset is in the (in)correct direction? Is it possible that Apache is getting the DST time form the OS and then ADDIND another hour to adjust (redundantly) for DST? IOW: Is Apache assuming that the time from the OS is always STANDARD time?

    ARS
     
  13. jpa

    jpa CLM

    Messages:
    8,024
    Likes Received:
    131
    Joined:
    May 28, 2001
    Location:
    Las Vegas NV
    I think dmobrien's on the right track.

    I remember using a windoze port of apache on an older desktop pc for tinkering purposes. I also remember adding this line to my config.sys (remember that file?)

    SET TZ=CST6CDT

    I wonder if that's still applicable? It's been a while since I've run any web servers, but that stuck in my head.

    -jpa
     
  14. gwalchmai

    gwalchmai Lucky Member

    Messages:
    28,915
    Likes Received:
    8,592
    Joined:
    Jan 9, 2002
    Location:
    Outside the perimeter
    Yes, I remember CONFIG.SYS. Fondly. ;)

    Anyway, I R&R'd Apache and it straightened everything up. Thanks for the suggestions, guys.