]> git.datanom.net - webcal.git/blob - utils/dateformat.class.php
75ebb45f608ad74628a23c616cdba57bbd94cd3c
[webcal.git] / utils / dateformat.class.php
1 <?php
2
3 include_once 'config.inc.php';
4 require_once 'helper.php';
5
6 class DateFormat {
7 /* private $tz;
8
9 function __construct($tz = '') {
10 if (empty($tz)) {
11 $tz = ($_SESSION['user_settings']->getTimeZone() !== NULL) ?
12 $_SESSION['user_settings']->getTimeZone() : TIMEZONE;
13 }
14 $timezone = date_default_timezone_get();
15 $tz_server = date("Z")/3600;
16 date_default_timezone_set($tz);
17 $tz_client = date("Z")/3600;
18 date_default_timezone_set($timezone);
19 $this->tz = $tz_client - $tz_server;
20 print "$timezone:$tz_server:$tz_client<br/>";
21 }*/
22
23 public function client2UTC($datetime) {
24 if (strcasecmp(substr($datetime, -1), "Z") === 0) {
25 // Time is in UTC already
26 return $datetime;
27 }
28
29 $timestamp = strtotime($datetime);
30
31 return gmdate("Ymd\THis\Z", $timestamp);
32 }
33
34 public function UTC2Client($datetime) {
35 //print "UTC2Client: $datetime\n";
36 if (strcasecmp(substr($datetime, -1), "Z") !== 0) {
37 // Time is not in UTC
38 return $datetime;
39 }
40
41 $timestamp = strtotime($datetime);
42
43 return date("Ymd\THis", $timestamp);
44 }
45
46 public function UTC2Local($datetime) {
47 if (strcasecmp(substr($datetime, -1), "Z") !== 0) {
48 // Time is not in UTC
49 return $datetime;
50 }
51
52 $offset = $_SESSION['timezone_offset'] - date("Z");
53 $timestamp = strtotime($datetime) + $offset;
54
55 return date("Ymd\THis", $timestamp);
56 }
57
58 }
This page took 0.097582 seconds and 6 git commands to generate.