note 102187 added to function.date-default-timezone-set
| From: | power2all at gmail dot com | Date: | Tue, 01 Feb 2011 16:30:24 +0000 |
| Subject: | note 102187 added to function.date-default-timezone-set | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176567@lists.php.net to get a copy of this message | ||
After poundering and knocking my head on the table, I finally got a proper fix for Windows and PHP
timezone handling.
Since Windows applies the DST to ActiveTimeBias in the registry, you only need this to apply.
The only problem is, that it cant use the timezone_set command.
You can request a response back in any date-format you wish, or use the default one given in the
function itself.
<?php
// Return proper time
function time_zone_fix($timeGiven = "H:i:s")
{
$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$time_bias = -($shell->RegRead("HKEY_LOCAL_MACHINE\\SYSTEM\\
CurrentControlSet\\Control\\TimeZoneInformation\\
ActiveTimeBias")) / 60;
$timestamp_bias = 60 * 60 * $time_bias;
echo $time_bias . "<br />";
return gmdate($timeGiven, strtotime($timestamp_bias . " seconds"));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 89.250.190.38
----
Manual Page -- http://www.php.net/manual/en/function.date-default-timezone-set.php
Edit -- https://master.php.net/note/edit/102187
Del: integrated -- https://master.php.net/note/delete/102187/integrated
Del: useless -- https://master.php.net/note/delete/102187/useless
Del: bad code -- https://master.php.net/note/delete/102187/bad+code
Del: spam -- https://master.php.net/note/delete/102187/spam
Del: non-english -- https://master.php.net/note/delete/102187/non-english
Del: in docs -- https://master.php.net/note/delete/102187/in+docs
Del: other reasons-- https://master.php.net/note/delete/102187
Reject -- https://master.php.net/note/reject/102187
Search -- https://master.php.net/manage/user-notes.php