From 5f4d1c43086dd1042d7eba922373c8e04e463083 Mon Sep 17 00:00:00 2001 From: Denis Kisselev Date: Sat, 27 Jul 2013 22:33:21 -0700 Subject: [PATCH] Fixed timezone issue for servers that do not have a default timezone set in PHP.ini --- README.md | 8 ++++++++ index.php | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 3cd1f32..d4963cf 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,14 @@ Set custom files and entire folders to ignore within your `/docs` folder. For fi } } +###Timezone +If your server does not have a default timezone set in php.ini, it may return errors when it tries to generate the last modified date/time for docs. To fix these errors, specify a timezone in your config file. Valid options are available in the [PHP Manual](http://php.net/manual/en/timezones.php). + + { + "timezone": "America/Los_Angeles" + } + + ## Running Remotely Copy the files from the repo to a web server that can run PHP 5.3 or greater. diff --git a/index.php b/index.php index 28a6bee..41d0c75 100644 --- a/index.php +++ b/index.php @@ -70,6 +70,13 @@ $tree = get_tree("docs", $base_url); $homepage_url = homepage_url($tree); $docs_url = docs_url($tree); +// If a timezone has been set in the config file, override the default PHP timezone for this application. +if(isset($options['timezone'])) +{ + date_default_timezone_set($options['timezone']); +} + + // Redirect to docs, if there is no homepage if ($homepage && $homepage_url !== '/') { header('Location: '.$homepage_url);