Timezones is a PSR-2 compliant package used for easily converting dates into UTC or into your local timezones. Bundled is also support for Laravel Facades and blade directives to make usage even easier!
Timezones has no dependencies or requires for standard usage.
And the following if you wish to run in dev mode and run tests.
Simplest installation is via composer.
composer require snscripts/timezones 1.*
or adding to your projects composer.json file.
To get started simply instantiate the Timezones object with the new keyword in PHP.
$Timezones = new \Snscripts\Timezones\Timezones;
Timezones requires no outside dependencies.
To use, first instantiate the object as described above. Once that has been done you can use one of two methods.
This method should be used when parsing an user inputted date to convert it to UTC ready for storing in your database.
$DateTimeis a required field and can either be an instance of \DateTime that was created with the correct local timezone or it can be a string which will be passed into an instance of \DateTime.
If $DateTime is an instance of \DateTime then $Timezone is not required and should default to null. If $DateTime is passed through as a string then $Timezone should either be an instance of \DateTimeZone or a string describing a valid timezone.
$format is an optional field that defaults to standard MySQL datetime format of YYYY-MM-DD HH:MM:SS.