ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Storage: Server Time vs. GMT

November 06, 2007 1:28pm

Subscribe [1]
  • #1 / Nov 06, 2007 1:28pm

    Mr Adams

    18 posts

    I was just wondering what, if any, are the benefits and draw backs in storing server dates/times over GMT dates/times? I’ve noticed that many popular open source scripts store the current server time and later apply an offset at runtime. Joomla, PunBB, PHPBB, Textpattern, Coppermine, etc all use that method, as far as I know.

    Here’s a basic example of how they handle dates:

    // From configuration settings.
    $timezone_offset = -5;
    
    // Whether Daylight Savings (Summer Time) is Enabled.
    // Also from configuration settings.
    $daylight_savings = false;
    
    // The stored server time timestamp fetched from database
    $server_timestamp = time();
    
    // Localized timestamp (server time with offset applied)
    $local_timestamp = ($server_timestamp + ($timezone_offset * 3600));
    
    // Account for Daylight savings.
    $local_timestamp += ($daylight_savings) ? 3600 : 0;
    
    // Get a localized date string. 
    $local_date_string = gmdate('r', $local_timestamp);
    
    echo $local_date_string;

    Is there any real difference?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases