note 86504 modified in function.date by thiago

From: Date: Wed, 22 Oct 2008 13:49:23 +0000
Subject: note 86504 modified in function.date by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-145588@lists.php.net to get a copy of this message
i figured i would post this, it's only useful for systems dealing with UTC and EST, but could easily be modified to support multiple timezones. this function will tell you whether it's daylight saving time for the eastern timezone using UTC localtime: <?php //checks whether DST in EST using UTC //can pass $time in unix timestamp, otherwise uses time() function est_isdst($time=NULL){ if(!$time) { $now = time(); }else { $now = $time; } if ( $now > strtotime(date('Y-m-d 6:59:59', strtotime('next Sunday', strtotime(date('Y', $now).'-3-7')))) && $now < strtotime(date('Y-m-d 6:00', strtotime('first Sunday', strtotime(date('Y', $now).'-11-0')))) ) { return true; }else { return false; } } ?> USAGE: <?php if(est_isdst()) { echo 'Its DST in EST Timezone!'; } ?> --was-- i figured i would post this, it's only useful for systems dealing with UTC and EST, but could easily be modified to support multiple timezones. this function will tell you whether it's daylight saving time for the eastern timezone using UTC localtime: //checks whether DST in EST using UTC //can pass $time in unix timestamp, otherwise uses time() function est_isdst($time=NULL){ if(!$time) { $now = time(); }else { $now = $time; } if ( $now > strtotime(date('Y-m-d 6:59:59', strtotime('next Sunday', strtotime(date('Y', $now).'-3-7')))) && $now < strtotime(date('Y-m-d 6:00', strtotime('first Sunday', strtotime(date('Y', $now).'-11-0')))) ) { return true; }else { return false; } } USAGE: if(est_isdst()) { echo 'Its DST in EST Timezone!'; } http://php.net/manual/en/function.date.php

« previous php.notes (#145588) next »