Drake CMS Official Forums - read-only archive

You are reading the Drake CMS Official Forums archive, available for historical purposes only.

Drake CMS has been rebranded into Lanius CMS, visit the new Lanius CMS Official Forums if you need support about Lanius CMS or Drake CMS -> Lanius CMS migration.



Home page General discussion > Time handling in PHP & in Drake Permanent link to this page
 
 
Author Message:
phpmaster
Time handling in PHP & in Drake
23 June 2007 11:10
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.

smileTry 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
 
legolas558
Re: Time handling in PHP & in Drake
23 June 2007 16:03
Anonymous Hi phpmaster,

timestamps stored in Drake CMS database are always UTC timestamps generated by the time() PHP function.

We use PHP4/PHP5 localization functions to modify the way date strings are rendered in the output, and we are using exclusively server-side localization because we aim at maximum accessibility and cannot rely on client rendering.

Hope this clears out any doubt about Drake CMS internal handling of timestamps smile
Regards
 
Top