note 120114 added to datetime.settimezone

From: Date: Thu, 03 Nov 2016 11:14:02 +0000
Subject: note 120114 added to datetime.settimezone
Groups: php.notes 
Request: Send a blank email to php-notes+get-207009@lists.php.net to get a copy of this message
Surprising that the timezone works only specified in the separated method in case if you'll use ->format('U'). this does NOT apply timezone +0200 in the $timestamp: <?php $date = new \DateTime(strtotime(time()), new DateTimeZone(system('date +%z'))); $timestamp = $date->format('U'); ?> this will apply timezone +0200 in the $timestamp: <?php $date = new \DateTime(strtotime(time())); $date->setTimezone(new DateTimeZone(system('date +%z'))); $timestamp = $date->format('U'); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 80.78.46.203 ---- Manual Page -- http://php.net/manual/en/datetime.settimezone.php Edit -- https://master.php.net/note/edit/120114 Del: integrated -- https://master.php.net/note/delete/120114/integrated Del: useless -- https://master.php.net/note/delete/120114/useless Del: bad code -- https://master.php.net/note/delete/120114/bad+code Del: spam -- https://master.php.net/note/delete/120114/spam Del: non-english -- https://master.php.net/note/delete/120114/non-english Del: in docs -- https://master.php.net/note/delete/120114/in+docs Del: other reasons-- https://master.php.net/note/delete/120114 Reject -- https://master.php.net/note/reject/120114 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#207009) next »