diff --git a/index.php b/index.php
index cf2644f6c..4d125f332 100644
--- a/index.php
+++ b/index.php
@@ -5,6 +5,7 @@ if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
exit(sprintf('You are running PHP %s, but Grav needs at least PHP %s to run.', $ver, $req));
}
+// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
exit('Please run: bin/grav install');
@@ -15,19 +16,19 @@ use Grav\Common\Grav;
// Register the auto-loader.
$loader = require_once $autoload;
-if (!ini_get('date.timezone')) {
- date_default_timezone_set('UTC');
-}
+// Set timezone to default, falls back to system if php.ini not set
+date_default_timezone_set(@date_default_timezone_get());
+// Get the Grav instance
$grav = Grav::instance(
array(
'loader' => $loader
)
);
+// Process the page
try {
$grav->process();
-
} catch (\Exception $e) {
$grav->fireEvent('onFatalException');
throw $e;
diff --git a/system/config/system.yaml b/system/config/system.yaml
index a3ac7e7a4..9edc14046 100644
--- a/system/config/system.yaml
+++ b/system/config/system.yaml
@@ -1,4 +1,5 @@
absolute_urls: false # Absolute or relative URLs for `base_url`
+timezone: '' # Valid values: http://php.net/manual/en/timezones.php
home:
alias: '/home' # Default path for home, ie /
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
index b9e5ce6af..606047acc 100644
--- a/system/src/Grav/Common/Grav.php
+++ b/system/src/Grav/Common/Grav.php
@@ -172,6 +172,10 @@ class Grav extends Container
ob_start('ob_gzhandler');
}
+ // Initialize the timezone
+ if ($this['config']->get('system.timezone')) {
+ date_default_timezone_set($this['config']->get('system.timezone'));
+ }
/** @var Debugger $debugger */
$debugger = $this['debugger'];