Git Product home page Git Product logo

php-timezone's Introduction

Timezone

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.