2017 © Pedro Peláez
 

library rock-date

A simple DateTime library for PHP with I18N

image

romeoz/rock-date

A simple DateTime library for PHP with I18N

  • Saturday, November 7, 2015
  • by romeOz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,189 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

A simple DateTime library for PHP

Latest Stable Version Total Downloads Build Status HHVM Status Coverage Status License, (*1)

Features

  • Supports many formats (m/d/Y, m/d/Y g:i A and other)
  • Customization of formats and options
  • i18n support
  • Extended DateInterval (support total months/weeks/hours/minutes/seconds between a dates)
  • Standalone module/component for Rock Framework

Table of Contents

Installation

From the Command Line:, (*2)

composer require romeoz/rock-date

In your composer.json:, (*3)

{
    "require": {
        "romeoz/rock-date": "*"
    }
}

Quick Start

use rock\date\DateTime;

(new DateTime)->format(); // output: current date in the format Y-m-d H:i:s

// default format 
(new DateTime)->isoDate(); // output: current date in the format Y-m-d

// modify date
DateTime::set('1988-11-12')->date(); //output: 11/12/1988

Custom format

$datetime = DateTime::set('1988-11-12');
$datetime->setFormats(['shortDate' => 'j / F / Y']);

$datetime->shortDate(); // output: 12 / November / 1988

Custom option format

$datetime = new DateTime('1988-11-12');
$datetime->setFormatOption('ago', function (DateTime $datetime) {
    return floor((time() - $datetime->getTimestamp()) / 86400) . ' days ago';
});

$datetime->format('d F Y, ago'); // output: 12 November 1988, 9574 days ago

i18n

$dateTime = new DateTime('1988-11-12');
$dateTime->setLocale('ru');

$dateTime->format('j  F  Y'); // output: 12  ноября  1988 

Difference/Interval between a dates

$diff = (new DateTime('2012-02-01'))->diff(new DateTime('2015-01-01'));

echo $diff->total_months; // output: 36
echo $diff->format('%R%tm months'); // output: +36 months

Added additional placeholders:, (*4)

  • %tm - total months
  • %tw - total weeks
  • %th - total hours
  • %ti - total minutes
  • %ts - total seconds

Documentation

Requirements

  • PHP 5.4+

License

The DateTime library is open-sourced software licensed under the MIT license., (*5)

The Versions

07/11 2015

dev-master

9999999-dev

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

07/11 2015

0.12.0

0.12.0.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

23/10 2015

0.11.0

0.11.0.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

22/10 2015

0.10.5

0.10.5.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

11/07 2015

0.10.4

0.10.4.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

02/07 2015

0.10.3

0.10.3.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

12/06 2015

0.10.2

0.10.2.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

20/05 2015

0.10.1

0.10.1.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime

05/03 2015

0.10.0

0.10.0.0

A simple DateTime library for PHP with I18N

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ruslan

date i18n datetime