braincrafted/human-date-bundle

Bundle for Symfony2 to transform dates in human readable form

dev-master 2014-05-14 20:59 UTC

This package is auto-updated.

Last update: 2024-11-20 09:34:06 UTC


README

DEPRECATED IN FAVOR OF cocur/human-date!

Build Status

Made in Vienna by Florian Eckerstorfer.

About

Transforms the given \DateTime object into a human date.

Installation

Composer

BraincraftedHumanDateBundle is on Packagist: braincrafted/human-date-bundle

{
    "require": {
        "braincrafted/human-date-bundle": "dev-master"
    }
}

Git

Of course, it is also possible to clone the Git repository:

git clone git://github.com/braincrafted/human-date-bundle.git

Usage

For example, assuming that today is 2012-08-18:

<?php

$t = new HumanDateTransformer();

echo $t->transform(new DateTime('now'));
// 'Today'

echo $t->transform(new DateTime('+1 day'));
// 'Tomorrow'

echo $t->transform(new DateTime('-1 day'));
// 'Yesterday'

echo $t->transform(new DateTime('2012-08-21'));
// 'Next Tuesday'

echo $t->transform(new DateTime('2012-09-30'));
// 'September 30'

echo $t->transform(new DateTime('2013-03-30'));
// 'March 30, 2013'

There is also a Twig extension included in the bundle

episode.airDate|humanDate

License

The MIT License (MIT) Copyright (c) 2012 Florian Eckerstorfer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.