![Travis] (https://travis-ci.org/JanGalek/DateTime.svg?branch=master)
Extension of PHP DateTime, using texts for difference dates. Supports multilanguages. Default language is english, for change you look down to examples. Optional is allow zero leading, default is allow.
The best way to install DateTime is using Composer:
$ composer require galek/datetime
or manual edit composer.json in your project
"require": {
"galek/datetime": "@dev"
}
Czech - cs
English - en
Slovakia - sk
Russia - ru
- User Format style
- Option for only bigest time (for example 0 year, 2 day, 3 minute,... return 2 day)
- Added Extension for Nette.
use \Galek\Helper\DateTime;
$date = new DateTime();
echo $date->diffToText('2016-02-06 15:30:02'); //return difference from today to this day
static date
use \Galek\Helper\DateTime;
$date = new DateTime('2016-01-06');
echo $date->diffToText('2016-02-06 15:30:02');
//return a month 15 hours 30 minutes 02 seconds ago
change language
use \Galek\Helper\DateTime;
$date = new DateTime('2016-01-06');
$date->setLanguage('cs');
echo $date->diffToText('2016-02-06 15:30:02');
//return před měsícem 15 hodinami 30 minutami 2 sekundami