note 29651 modified in function.localtime by danbrown

From: Date: Sun, 20 Jul 2008 03:22:43 +0000
Subject: note 29651 modified in function.localtime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142057@lists.php.net to get a copy of this message
To calculate the delta between the local time and UTC: <?php function tzdelta ( $iTime = 0 ) { if ( 0 == $iTime ) { $iTime = time(); } $ar = localtime ( $iTime ); $ar[5] += 1900; $ar[4]++; $iTztime = gmmktime ( $ar[2], $ar[1], $ar[0], $ar[4], $ar[3], $ar[5], $ar[8] ); return ( $iTztime - $iTime ); } ?> So if your system is in DST, tzdelta should return -18000 (five hours less). --was-- To calculate the delta between the local time and UTC: function tzdelta ( $iTime = 0 ) { if ( 0 == $iTime ) { $iTime = time(); } $ar = localtime ( $iTime ); $ar[5] += 1900; $ar[4]++; $iTztime = gmmktime ( $ar[2], $ar[1], $ar[0], $ar[4], $ar[3], $ar[5], $ar[8] ); return ( $iTztime - $iTime ); } So if your system is in DST, tzdelta should return -18000 (five hours less). http://php.net/manual/en/function.localtime.php

« previous php.notes (#142057) next »