From afd7b77b4c79a0450a6ef0489ca383c156111173 Mon Sep 17 00:00:00 2001
From: VirtualTam <virtualtam@flibidi.net>
Date: Tue, 4 Aug 2015 18:31:16 +0200
Subject: Installation: default to the server's timezone

Modifications
 - attempt to use the server's timezone
 - if none is set, use UTC
 - TimeZone: apply coding conventions
   - variable naming
   - no closing PHP tag

Relates to #274

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
---
 index.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'index.php')

diff --git a/index.php b/index.php
index 1439ec2f..e3b612c8 100644
--- a/index.php
+++ b/index.php
@@ -5,10 +5,12 @@
 // Licence: http://www.opensource.org/licenses/zlib-license.php
 // Requires: PHP 5.3.x
 // -----------------------------------------------------------------------------------------------
-// NEVER TRUST IN PHP.INI
-// Some hosts do not define a default timezone in php.ini,
-// so we have to do this for avoid the strict standard error.
-date_default_timezone_set('UTC');
+
+// Set 'UTC' as the default timezone if it is not defined in php.ini
+// See http://php.net/manual/en/datetime.configuration.php#ini.date.timezone
+if (date_default_timezone_get() == '') {
+    date_default_timezone_set('UTC');
+}
 
 // -----------------------------------------------------------------------------------------------
 // Hardcoded parameter (These parameters can be overwritten by editing the file /data/config.php)
-- 
cgit v1.2.3