Initial commit.
This commit is contained in:
32
lib/php/monica/timezone.inc.php
Normal file
32
lib/php/monica/timezone.inc.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// File name: timezone.inc.php
|
||||
// Description: PHP subroutines to deal with time zone information
|
||||
// Date: 2004-04-05
|
||||
// Author: imacat <imacat@pristine.com.tw>
|
||||
// Copyright: Copyright (C) 2004-2007 Pristine Communications
|
||||
|
||||
// timezone_iso: Return the timezone in ISO 8601 format
|
||||
function timezone_iso()
|
||||
{
|
||||
// Cache the result
|
||||
static $cache;
|
||||
// Return the cache
|
||||
if (isset($cache)) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// Calculate the time zone string
|
||||
$tzsec = date("Z");
|
||||
$tzsign = ($tzsec >= 0? "+": "-");
|
||||
$tzsec = abs($tzsec);
|
||||
$tzmin = floor($tzsec / 60);
|
||||
$tzsec = $tzsec % 60;
|
||||
$tzhr = floor($tzmin / 60);
|
||||
$tzmin = $tzmin % 60;
|
||||
$tz = sprintf("%s%02d:%02d", $tzsign, $tzhr, $tzmin);
|
||||
// Cache it
|
||||
$cache = $tz;
|
||||
return $tz;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user