Timezone
, (*1)
Version: 1.0.0br/, (*2)
Timezone fixes issues you may run into with PHP and it's date.timezone
ini setting.
This library should only be a dependency on end user applications and frameworks.
It should not be a dependency on smaller libraries or plugins.br/
It can be installed in whichever way you prefer, but I recommend Composer., (*3)
{
"require": {
"adlawson/timezone": "1.0.0"
}
}
When should I consider using this library?
It is useful if you ever see this warning, (*4)
Exception: DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use
the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are
still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now,
but please set date.timezone to select your timezone.
This library works by setting the default timezone to UTC
if it isn't already set in php.ini
.
Unfortunately, it does so by ignoring PSR-1#2.3
and executes itself when the file is included., (*5)
Usage
If you installed this library with composer, all you need to do is include composer's autoloader., (*6)
<?php
require 'vendor/autoload.php';
Otherwise, you'll need to include the file in this library directly., (*7)
<?php
require '/path/to/adlawson/timezone/lib/timezone.php';
Notes
This is a fairly horrible but convenient way to cover up the timezone issue in PHP.
It's by no means a silver bullet and should only be used if you're confident you know what it actually does., (*8)
When I wrote this, I had seen a very similar fix somewhere on github but I couldn't for the life of me find it again.
If anybody knows which library I'm referring to, please send me a link. Thanks., (*9)
License
The content of this library is released under the MIT License by Andrew Lawson.br/
You can find a copy of this license at http://www.opensource.org/licenses/mit or in LICENSE
, (*10)