Download the PHP package snscripts/timezones without Composer

On this page you can find all versions of the php package snscripts/timezones. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package timezones

Timezones

Author Latest Version Software License Build Status

Introduction

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!

Installation

Composer

Simply require the package via composer into your app.

composer require mbarlow/timezones 2.*

Setup

To get started simply instantiate the Timezones object with the new keyword in PHP.

Laravel

Bundled with this package is a Laravel Service provider that is setup for auto-discovery.

If you are not using Laravel 5.5 then you can add the following Service Provider to your config/app.php config.

The service provider will bind the Timezones Object to the container allowing you to type hint in the object.

Usage

To use, first instantiate the object or typehint the object into your method.

convertToUTC

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 $tz is not required and should default to null. If $dateTime is passed through as a string then $tz 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.

convertToLocal

This method should be used in your "views or in your API endpoints" to transform a UTC date stored within your database into the local timezone for the user viewing the page or requesting the data.

$dateTime is a required field and can either be an instance of \DateTime that was created with the correct UTC timezone or it can be a string which will be passed into an instance of \DateTime.

$tz is a required field and can either be an instance of \DateTimeZone or a string describing a valid timezone and should be the timezone of the end user.

$format is an optional field that defaults to standard MySQL datetime format of YYYY-MM-DD HH:MM:SS.

timezoneList

This method can be used for API endpoints or within your templates to generate an array of formatted timezones. The generated array will return an associative array with the timezone as the key and a nice label with offset as the value.

Laravel Extras

If you have installed the package into a Laravel application a few extra goodies are available.

Facade

Should you prefer to use a Facade, one has been bundled and made available with the Service Provider. The facade is available at `\Timezones'.

Both methods described in the "Usage" section above are available.

\Timezones::convertToUTC();
\Timezones::convertToLocal();

Blade Directive

A blade directive will also be registered by the Service Provider. This only supports the convertToLocal method and is designed for use within your blade templates to convert a UTC datetime into the end users time and display on the page in the correct format.

@displayDate($dateTime, $tz, $format)

All parameters match those defined for the convertToLocal method however all fields are required when using the blade directive.

Testing

If you wish to run the tests, clone out the repository

Change to the root of the repository and run composer install with the dev dependencies

A script is defined in the composer.json to run both the code sniffer and the unit tests

Or run them individually as required

Changelog

You can view the changelog HERE

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.


All versions of timezones with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package snscripts/timezones contains the following files

Loading the files please wait ....