diff --git a/README.md b/README.md index 7a6b370..a3e8607 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ cp ./config.ini ./data/config.ini ``` ## Install -If you have decied that you don't want to use Docker, you can intall it manually. +If you have decided that you don't want to use Docker, you can intall it manually. **Requirements:** Apache 2.0*, PHP 7.4, MariaDB 10.1 @@ -153,7 +153,10 @@ To check if your server is set up correctly, turn on a debug mode (in config add * Display posts to chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#to=2017-06`. * Combine parameters in url using `&`, e.g. show posts between dates: `http://blog/#from=2017-06&to=2017-08`. -## Language support +## Localisation +Timezone can be set using `TZ` environment variable. List of supported values can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + +### Language support Feel free to create new PR and add a new language. Specify language in config or in url: `http://blog/?hl=sk`. * en - 🇬🇧 English diff --git a/app/db.class.php b/app/db.class.php index 5ff3dae..07edf32 100644 --- a/app/db.class.php +++ b/app/db.class.php @@ -48,7 +48,14 @@ class DB // Password Config::get_safe('mysql_pass', '') ); - $this->_PDO->exec('SET NAMES utf8'); + + $this->_PDO->exec( + // Set charset + 'SET NAMES utf8;'. + + // Set timezone + 'SET time_zone="'.date('P').'";' + ); } catch (PDOException $e) { throw new DBException($e->getMessage()); } diff --git a/common.php b/common.php index 82ef14d..87d1c8e 100644 --- a/common.php +++ b/common.php @@ -27,8 +27,12 @@ if(Config::get_safe('debug', false)){ // Language Lang::load(empty($_GET["hl"]) ? Config::get("lang") : $_GET["hl"]); +// Timezone +if(false !== ($TZ = getenv('TZ'))) { + date_default_timezone_set($TZ); + ini_set('date.timezone', $TZ); +} + // Start session ini_set('session.cookie_httponly', 1); session_start(); - - diff --git a/docker-compose.yml b/docker-compose.yml index 51f8cfa..04ae948 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,8 @@ services: webserver: build: ./ container_name: blog_apache + environment: + TZ: Europe/Vienna restart: unless-stopped ports: - ${HTTP_PORT-80}:80