PHPackages                             adlawson/timezone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. adlawson/timezone

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adlawson/timezone
=================

UTC default timezone

1.0.0(12y ago)314.3k↓33.3%118MITPHPPHP &gt;=5.3

Since Aug 16Pushed 12y ago1 watchersCompare

[ Source](https://github.com/adlawson/php-timezone)[ Packagist](https://packagist.org/packages/adlawson/timezone)[ Docs](http://github.com/adlawson/timezone)[ RSS](/packages/adlawson-timezone/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (18)

Timezone
========

[](#timezone)

[![Timezone](https://camo.githubusercontent.com/04059c2b3fff23cc003674eeb256a7d3430bf21c952bb044c46a75c71917a23e/687474703a2f2f73747265616d312e676966736f75702e636f6d2f76696577362f323836323638332f6261636b2d746f2d7468652d6675747572652d6f2e676966)](https://camo.githubusercontent.com/04059c2b3fff23cc003674eeb256a7d3430bf21c952bb044c46a75c71917a23e/687474703a2f2f73747265616d312e676966736f75702e636f6d2f76696577362f323836323638332f6261636b2d746f2d7468652d6675747572652d6f2e676966)

**Version:** *1.0.0*

**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.
It can be installed in whichever way you prefer, but I recommend [Composer](https://packagist.org/packages/adlawson/timezone).

```
{
    "require": {
        "adlawson/timezone": "1.0.0"
    }
}
```

### When should I consider using this library?

[](#when-should-i-consider-using-this-library)

It is useful if you ever see this warning

```
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`](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md#23-side-effects) and executes itself when the file is included.

### Usage

[](#usage)

If you installed this library with composer, all you need to do is include composer's autoloader.

```
