Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Timezone Laravel Package

adlawson/timezone

Sets PHP’s default timezone to UTC when date.timezone isn’t configured, preventing DateTime “not safe to rely on system timezone” warnings. Auto-runs on include (side effect), intended for end-user apps/frameworks, not libraries.

View on GitHub
Deep Wiki
Context7

Timezone

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.

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

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 and executes itself when the file is included.

Usage

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

<?php
require 'vendor/autoload.php';

Otherwise, you'll need to include the file in this library directly.

<?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.

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.

License

The content of this library is released under the MIT License by Andrew Lawson. You can find a copy of this license at http://www.opensource.org/licenses/mit or in LICENSE

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky