note 61625 added to function.date
| From: | NathanielGibson at osu1 dot php dot net | Date: | Wed, 08 Feb 2006 02:36:09 +0000 |
| Subject: | note 61625 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103257@lists.php.net to get a copy of this message | ||
<?php
$timezone_mst = -7;
$timezone_est = -5;
echo tz_convert("2006-02-07 12:13:00",$timezone_mst,$timezone_est,"m/d/Y g:i
A");
//outputs: 02/07/2006 2:13 PM
function tz_convert($datetime,$tz_from,$tz_to,$format='Y-m-d H:i:s'){
return date($format,strtotime($datetime)+(3600*($tz_to - $tz_from)));
}
?>
This is my timezone converter function. It will convert a datetime field from one time zone to
another. It uses integers to represent the different timezones so that you can easily use a UTC
timezone value. It could easily be expanded to add a number of things like allowing a user to put
in longitudinal coordinates instead of integers for the from and to timezone arguments.
----
Server IP: 64.71.164.2
Probable Submitter: 69.252.206.39
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61625
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61625&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61625&report=yes
Search -- http://master.php.net/manage/user-notes.php