note 53002 modified in function.gmdate by danbrown

From: Date: Sun, 20 Jul 2008 03:14:14 +0000
Subject: note 53002 modified in function.gmdate by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142036@lists.php.net to get a copy of this message
Want to put different International Times in your web? First create a database including the GMT and the DST (find it f.i. at timeanddate.com). Be careful, because there are several different DST dates and options. Once you have your function which calculates the GMT hour difference (it can be a decimal!!), sum it to the Unix Time (remember that unix time is GMT, not local: f.i. gmdate("U")===date("U)). Don't forget to recalculate the GMT difference to seconds before it. Then format your date using gmdate() (not date()!) and... you've got your International Time! <?php $city["Name"] = "Barcelona"; $city["GMT"] = 1.0; $city["actualDST"] = 1.0; //Because it's summer time $gmt_diff = $city["GMT"]+$city["actualDST"]; //your functions for getting the hour difference betweer the city and the GMT $city_time = time()+($gmt_diff*3600); //sum the timestamps echo gmdate("H:i",$city_time); //echo the formatted date echo " h. in the beautiful city of ".$city["Name"]; ?> --was-- Want to put different International Times in your web? First create a database including the GMT and the DST (find it f.i. at timeanddate.com). Be careful, because there are several different DST dates and options. Once you have your function which calculates the GMT hour difference (it can be a decimal!!), sum it to the Unix Time (remember that unix time is GMT, not local: f.i. gmdate("U")===date("U)). Don't forget to recalculate the GMT difference to seconds before it. Then format your date using gmdate() (not date()!) and... you've got your International Time! <?php $city["Name"] = "Barcelona"; $city["GMT"] = 1.0; $city["actualDST"] = 1.0; //Because it's summer time $gmt_diff = $city["GMT"]+$city["actualDST"]; //your functions for getting the hour difference betweer the city and the GMT $city_time = time()+($gmt_diff*3600); //sum the timestamps echo gmdate("H:i"); //echo the formatted date echo " h. in the beautiful city of ".$city["Name"]; ?> http://php.net/manual/en/function.gmdate.php

« previous php.notes (#142036) next »