2017 © Pedro Peláez
 

library utcdatetime

Provides a datetime-implementation that is always UTC

image

utcdatetime/utcdatetime

Provides a datetime-implementation that is always UTC

  • Thursday, February 26, 2015
  • by heiglandreas
  • Repository
  • 1 Watchers
  • 1 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

UTCDateTime

A small library that always uses UTC for your DateTime-Objects no matter what you input., (*1)

Build Status Code Climate Scrutinizer Code Quality, (*2)

Installation

UTCDateTime is installed via composer. Call composer require utcdatetime/utcdatetime from the commandline in your project., (*3)

Alternatively you can include the following line in your composer.json inside the require-section:, (*4)

"utcdatetime/utcdatetime" : "stable"

Usage

Use the UTCDateTime- or UTCDateTimeImmutable-Object just like PHPs own DateTime-Objects. You do not have to rewrite any productive code. Just add use UTCDateTime/DateTime resp. use UTCDateTime\DateTimeimmutable to the use-section of your PHP-file. That will cause PHP to use the UTCDateTime-Objects instead of the PHP-Internal DateTime-Objects., (*5)

Calls to setTimeZone will be ignored, all other calls will be executed just as before. The only difference will be, that no matter what you put into the DateTime-Objects, it will always contain the UTC-representation of your date. And there is no way to change that., (*6)

So any Datetime-data will always be correctly converted to UTC and you can then work with that like so:, (*7)

use UTCDateTime\DateTime;
$date = new DateTime('2014-11-03 12:34:56', new DateTimeZone('Europe/Berlin'));
echo $date->format(DateTime::RFC3339);
// 2014-11-03T10:34:56+00:00

Additional Constants

This package also introduce some more formating-constants., (*8)

Those include:, (*9)

  • DateTime::RFC7231 for formatting date according to RFC 7231
  • DateTime::PDF for formatting dates for internal PDF-Storage

Licence

This code is licensed under the MIT-License., (*10)

Contributing

Contributions are always welcome. Fork the repo, do whatever you like and open a pull request!, (*11)

The Versions

26/02 2015

dev-master

9999999-dev http://github.com/heiglandreas/UTCDateTime

Provides a datetime-implementation that is always UTC

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

datetime utc gmt

04/11 2014

dev-feature/featuerFlagForThrowing

dev-feature/featuerFlagForThrowing http://github.com/heiglandreas/UTCDateTime

Provides a datetime-implementation that is always UTC

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

datetime utc gmt

03/11 2014

1.0.0

1.0.0.0 http://github.com/heiglandreas/UTCDateTime

Provides a datetime-implementation that is always UTC

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

datetime utc gmt

31/10 2014

v0.1

0.1.0.0 http://github.com/heiglandreas/UTCDateTime

Provides a datetime-implementation that is always UTC

  Sources   Download

MIT

The Development Requires

datetime utc gmt