note 58773 deleted from function.gmdate by danbrown
| From: | danbrown@php.net | Date: | Sun, 20 Jul 2008 03:12:32 +0000 |
| Subject: | note 58773 deleted from function.gmdate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142033@lists.php.net to get a copy of this message | ||
Note Submitter: faraz at gmail dot com
----
Hi i was having a problem in converting a date to any time zone so I wrote my own function which
coverts a given date and time to other time zone equivalent
function printByTimeZone($mytime,$mydate,$mytimezone)
{
//assuming timezone in format +05:00 or -4:30
$conTime = $mytime;
$conDate = $mydate;
$tzonehr=substr($mytimezone,1,2);
$tzonesec=substr($mytimezone,4,2);
$sign= substr($mytimezone,0,1);
$timezone=intval($tzonehr)*60 + ( intval($tzonesec)*3600);
Switch($sign)
{
Case -:
$timezone=$timezone*(-1);
Break;
}
// write a method to extract your hours,min,sec,day,month,year (all should be in numeric form)
$TimeStamp= mktime($yourhours, $yourmins,$yoursecs,$yourmonth,$yourday ,$youryear ,-1);
$TimeStamp=$TimeStamp+$_GET['TimeZone'];
$GMTDateTime=gmdate("H:i:s D M d Y",$TimeStamp);
return $GMTDateTime;
}