note 23169 added to function.date

From: Date: Thu, 11 Jul 2002 01:24:59 +0000
Subject: note 23169 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-32872@lists.php.net to get a copy of this message
If you get the current date in a different timezone, try this function: /* $current should be the timezone on the current machine, $target is the timezone you want to calculate. Both should be in hours. For example, GMT -05:00 should be -5. GMT +12:00 should be 12. You can use the returned timestamp with the date function. ex: echo date('r', zonechange(-5, 10)); would echo the date for a +10:00 timezone on a machine in -05:00. */ function zonechange ($current, $target) { $current = -1 * $current; $zonedate = mktime(date('G'), date('i'), date('s'), date('n'), date('j'), date('Y'), 1) + (($current + $target) * 3600); return $zonedate; } -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+23169 http://master.php.net/manage/user-notes.php?action=delete+23169 http://master.php.net/manage/user-notes.php?action=reject+23169

« previous php.notes (#32872) next »