note 95834 added to function.date
| From: | robert at extremedesigns dot de | Date: | Sun, 24 Jan 2010 23:26:16 +0000 |
| Subject: | note 95834 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165261@lists.php.net to get a copy of this message | ||
if you wish to output a local time, instead of using date_default_timezone_get() and
date_default_timezone_set() to manipulate your current timezone, simply create a new DateTime
object:
$timezone = new DateTimeZone( "Europe/London" );
$date = new DateTime();
$date->setTimezone( $timezone );
echo $date->format( 'H:i:s A / D, M jS, Y' );
-> 22:59:34 PM / Sun, Jan 24th, 2010
Irrespective of current server location, this will output the local time in London, Europe.
No need to reset the server timezone back to the previous setting.
----
Server IP: 64.71.164.2
Probable Submitter: 74.221.136.242
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/95834
Del: integrated -- https://master.php.net/note/delete/95834/integrated
Del: useless -- https://master.php.net/note/delete/95834/useless
Del: bad code -- https://master.php.net/note/delete/95834/bad+code
Del: spam -- https://master.php.net/note/delete/95834/spam
Del: non-english -- https://master.php.net/note/delete/95834/non-english
Del: in docs -- https://master.php.net/note/delete/95834/in+docs
Del: other reasons-- https://master.php.net/note/delete/95834
Reject -- https://master.php.net/note/reject/95834
Search -- https://master.php.net/manage/user-notes.php