2017 © Pedro Peláez
 

library datehelper

Date manipulation and output

image

natedrake/datehelper

Date manipulation and output

  • Sunday, March 26, 2017
  • by natedrake
  • Repository
  • 1 Watchers
  • 0 Stars
  • 142 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

DateHelper

Build Status Latest Stable Version Latest Unstable Version License composer.lock, (*1)

Total Downloads Monthly Downloads Daily Downloads, (*2)

Manipulate PHP Date

Install

To install this package add it as a dependency using composer, (*3)

composer.json ````$json "require": { "natedrake/datehelper": "^0.1.4" }, (*4)


### Usage ````php <?php use Natedrake\DateHelper\Date; use Natedrake\DateHelper\DateFormat; $datePosted=date('2015-08-02 10:36:15'); $date=Date::get()->getDifferenceFromNow($datePosted);

returns the amount of time since the date provided in date posted.
E.g. 10 seconds ago, less than a minute ago, a week ago, 3 weeks ago, a fortnight ago, etc, (*5)

Classes

Natedrake\DateHelper\Date

Usage:
$ordinal=Date::<function>([parameter]);
Example:
$ordinal=Date::ordinal(12);

returns '12th', (*6)

Methods:
Date::differenceFromNow($date);

returns the difference since the provided date. E.g 10 seconds ago, a week ago, a fortnight, ago, 3 weeks ago, etc, (*7)

Date::ordinal($number);

returns the ordinal for the number provided. E.g. 1st, 10th, 3rd, etc., (*8)

Natedrake\DateHelper\DateFormat

Usage:
DateFormat::get()->date(<date>)-><function>([paramater]);
Example:
$isLeapYear=DateFormat::get()->date('2012-01-01')->isLeapYear();

returns true, or false if year of date isn't a leap year, (*9)

Methods:
DateFormat::get();

returns a DateFormat object to use, (*10)

DateFormat::get()->date($date);

set the date of the date format object, (*11)

DateFormat::get()->date($date)->format('Y-m-d H:i:s);

returns the date in the provided format., (*12)

DateFormat::get()->date($date)->format(DateFormat::ISO8601);

There are a list of predefined formats in the DateFormat class., (*13)

DateFormat::EASY        *25th of March 2016 09:00:00 AM*
DateFormat::BIG         *2016-03-25 09:00:00*
DateFormat::LITTLE      *25-03-2016 09:00:00*
DateFormat::MIDDLE      *03-25-2016 09:00:00*
DateFormat::ISO8601     *2016-03-25T09:00:00+01:00*
DateFormat::RFC2822     *Fri, 25 Mar 2016 09:00:00 +0100*
DateFormat::EPOCH       *1458892800*

DateFormat::DAY         *Friday*
DateFormat::MNT         *Mar*
DateFormat::YEAR        *2016*

DateFormat::GMT         *+01:00* // Time zone difference from GMT
DateFormat::LEAP        *1*      // Returns 1 if year is a leap year

The Versions

26/03 2017

dev-master

9999999-dev

Date manipulation and output

  Sources   Download

MIT

The Development Requires

26/03 2017

v1.0.0

1.0.0.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires

11/07 2015

0.1.4

0.1.4.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires

08/07 2015

0.1.3

0.1.3.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires

07/07 2015

0.1.2

0.1.2.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires

07/07 2015

0.1.1

0.1.1.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires

07/07 2015

0.1

0.1.0.0

Date manipulation and output

  Sources   Download

MIT

The Development Requires