note 94784 added to datetime.settimezone

From: Date: Tue, 24 Nov 2009 23:13:17 +0000
Subject: note 94784 added to datetime.settimezone
Groups: php.notes 
Request: Send a blank email to php-notes+get-163254@lists.php.net to get a copy of this message
The timestamp value represented by the DateTime object is not modified when you set the timezone using this method. Only the timezone, and thus the resulting display formatting, is affected. This can be seen using the following test code: <?php $MNTTZ = new DateTimeZone('America/Denver'); $ESTTZ = new DateTimeZone('America/New_York'); $dt = new DateTime('11/24/2009 2:00 pm', $MNTTZ); var_dump($dt->format(DATE_RFC822), $dt->format('U')); $dt->setTimezone($ESTTZ); var_dump($dt->format(DATE_RFC822), $dt->format('U')); /** Output: string(29) "Tue, 24 Nov 09 14:00:00 -0700" string(10) "1259096400" string(29) "Tue, 24 Nov 09 16:00:00 -0500" string(10) "1259096400" **/ ?> As such, you can use this to easily convert between timezones for display purposes. ---- Server IP: 64.71.164.2 Probable Submitter: 68.47.152.108 ---- Manual Page -- http://www.php.net/manual/en/datetime.settimezone.php Edit -- https://master.php.net/note/edit/94784 Del: integrated -- https://master.php.net/note/delete/94784/integrated Del: useless -- https://master.php.net/note/delete/94784/useless Del: bad code -- https://master.php.net/note/delete/94784/bad+code Del: spam -- https://master.php.net/note/delete/94784/spam Del: non-english -- https://master.php.net/note/delete/94784/non-english Del: in docs -- https://master.php.net/note/delete/94784/in+docs Del: other reasons-- https://master.php.net/note/delete/94784 Reject -- https://master.php.net/note/reject/94784 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163254) next »