Anonymous |
hi again
I read the good article on Timezones in
Drake.
My own way, which has worked great in
my scripts is to define SCRIPT Location (server) as using
GMT+0000 time.
My Timestamps are Always
stored in my database as return value of time(). I store no
'date values', if I can avoid this. This Timestamp value is
Free from any locale offsets. So it will be = GMT+0000.
With the new default_time_zone_set()
function it is easy, for example in your
settings.php / include/common.php to Override the server Time Zone and so make all date
displays NEUTRAL and independent of SERVERs local times.
Good for example if you move your database /
webscripts to a Host/Server somewhere else in The World. What I want is in short, to make all times/dates TOTALLY
TRANSPARENT TO and FREE from local server. ----
This little script shows how this can be done. And what
good things we have to play with. PHP has good functions for
this.
What we may have to use to detect
guests/visitors locale times. Some small Javascript to
figure out Browser data. There are many such script examples
around the web. Even where the java tells PHP this value.
Try this! Code:<html> <head> <title>Time Info</title> </head> <body> <?php
$oldzone =
date_default_timezone_get(); $void =
date_default_timezone_set('GMT'); $stamp=time();
echo "<pre>"; echo "\n"; echo 'GETtimezone'."\t: ".$oldzone; echo
"\n\n"; echo 'SETtimezone'."\t:
".date_default_timezone_get(); echo "\n"; echo 'GMTtime'."\t\t:
".gmdate("H:i:s",$stamp); echo
"\n"; echo 'LOCALtime'."\t:
".date("H:i:s",$stamp); echo
"\n"; echo 'GMToffset/DST'."\t:
".date("Z / I",$stamp); echo
"\n\n"; $void =
date_default_timezone_set($oldzone); echo
'RESTOREzone'."\t: ".date_default_timezone_get(); echo "\n"; echo "</pre>\n";
?> </body> </html> My server outputs this: Quote:GETtimezone :
Europe/Stockholm
SETtimezone : GMT GMTtime :
10:06:10 LOCALtime : 10:06:10 GMToffset/DST : 0 / 0
RESTOREzone : Europe/Stockholm
Regards phpMaster |