Skip to content

TroiaStudio/DateTime

Repository files navigation

DateTime

![Travis] (https://travis-ci.org/JanGalek/DateTime.svg?branch=master) Total Downloads Latest Stable Version License Monthly Downloads

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.

Package Installation

The best way to install DateTime is using Composer:

$ composer require galek/datetime

Packagist - Versions

or manual edit composer.json in your project

"require": {
    "galek/datetime": "@dev"
}

Actual support languages:

Czech - cs
English - en
Slovakia - sk
Russia - ru

ToDo

  1. User Format style
  2. Option for only bigest time (for example 0 year, 2 day, 3 minute,... return 2 day)
  3. Added Extension for Nette.

Usage

    use \Galek\Helper\DateTime;

    $date = new DateTime();

    echo $date->diffToText('2016-02-06 15:30:02'); //return difference from today to this day

Examples

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

About

[ABANDONED] Translate datetime and differences

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages