Skip to content

Commit

Permalink
Better way of handling the timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
zaydons committed Dec 28, 2024
1 parent d02e77d commit 4f3b12b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ You should take this generated password and populate it in the `DB_PASS` of your
- `DB_PASS` should be set the password as detailed above.
- `DB_NAME` should be set to `address_book`.
- `SITE_URL` should be set to the address from which the system will be accessible from. Typically http://localhost/ is acceptable.
- `TZ` should be the timezone. Default is 'UTC'. (https://www.php.net/manual/en/timezones.php)

5. (OPTIONAL) To define a timezone orther than the default 'Europe/London', in your `docker-compose.yml` add the following under the 'php-fpm' service:

```yml
environment:
- TZ=America/New_York
```
### 2. Manual Installation
If you wish to set up the system manually then this too can be done.
Expand Down Expand Up @@ -86,12 +91,34 @@ You should then set your `settings.local.inc.php` values to match your environme
- `DB_PASS` should be set the password for the user which you created.
- `DB_NAME` should be set to `address_book`, if you used the default set up.
- `SITE_URL` should be the FQDN of the address of the server.
- `TZ` should be the timezone. Default is 'UTC'. (https://www.php.net/manual/en/timezones.php)

#### Web Server Configuration

You should configure your web server so that the document root is set as the [html](html) directory. However, the web server user for your configuration should have access to both the [html](html/) and [includes](includes/) directories.

#### Optional Configuration
To define a timezone other than the default 'Europe/London', it varies by web server.

##### Apache

In your VirtualHost definition, add the following
```bash
<VirtualHost localhost:80>
...
SetEnv TZ America/New_York
</VirtualHost>
```

##### Nginx (Untested)

In your php-fpm definition, add the following
```bash
location / {
...
fastcgi_param TZ America/New_York;
}
```

### Testing

Once you have finished running one of the above methods you can then test if the system is working by visiting the address of the server in a browser.
Expand Down
5 changes: 4 additions & 1 deletion includes/settings.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@
defined("PAGELINK_APIUPDATE") ? null : define("PAGELINK_APIUPDATE", "update-api.php");

// Server time zone
date_default_timezone_set(getEnv("TZ"));
if ( !isset($_SERVER['TZ']) ) {
putenv('TZ=' . "Europe/London");
}
date_default_timezone_set(getenv('TZ'));

// Autoload classes so that they are called as and when they are required
spl_autoload_register(function($class_name) {
Expand Down

0 comments on commit 4f3b12b

Please sign in to comment.