2017 © Pedro Peláez
 

library date-formatter

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

image

org_heigl/date-formatter

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

  • Friday, April 22, 2016
  • by heiglandreas
  • Repository
  • 1 Watchers
  • 2 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

DateFormatter

Build Status Code Climate Test Coverage Scrutinizer Code Quality, (*1)

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants, (*2)

Installation

composer require org_heigl/date-formatter, (*3)

Usage


use Org_Heigl\DateFormatter\FormatterFacade as Formatter; $date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin')); echo Formatter::format($date, 'PDF'); // Prints "20131203122334+01'00'"

Currently the following formatters are available:, (*4)

  • PDF
  • ATOM
  • COOKIE
  • RFC_822
  • RFC_850
  • RFC_1036
  • RFC_1123
  • RFC_3339
  • RSS
  • W3C
  • MYSQL

Extending

You can add your own formatter by creating a class that implements the Org_Heigl\DateFormatter\Formatter\FormatterInterface. This class can then either be used directly like in this example:, (*5)

use Org_Heigl\DateFormatter\DateFormatter as Formatter;

$formatter = new Formatter(new MyCoolClassImplementingFormatterInterface());

$date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin'));

echo $formatter->format($date);
// Prints whatever you formatted the given date to ;)

To be able to use it with the FormatterFacade you have to announce the Folder containing the formatter to the class like in this example:, (*6)

use Org_Heigl\DateFormatter\FormatterFacade as Formatter;

// Announce the Folder containing your formatter to the class
Formatter::addFormatterFolder('/absolute/Path/To/Your/Formatter/Folder');

$date = new DateTime('2013-12-03 12:23:34', new DateTimeZone('Europe/Berlin'));

echo Formatter::format($date, 'WhateverYouCalledYourFormatter');
// Prints WhateverYourFormatterDoes ;)

Self-Defined formatters will always be called instead of default formatters. So when you have a formatter for "PDF" in your added folder that formatter will be called instead of the default formatter!, (*7)

The Versions

22/04 2016

dev-master

9999999-dev

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

  Sources   Download

MIT

The Requires

 

The Development Requires

date datetime format

25/03 2016

1.1.0

1.1.0.0

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

  Sources   Download

MIT

The Requires

 

The Development Requires

24/03 2016

1.0.1

1.0.1.0

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

  Sources   Download

MIT

The Requires

 

The Development Requires

24/03 2016

1.0.0

1.0.0.0

Extendable Library to format DateTimes using Zend-Frameworks Date-Constants

  Sources   Download

MIT

The Requires

 

The Development Requires