PHP code example of natedrake / datehelper

1. Go to this page and download the library: Download natedrake/datehelper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

natedrake / datehelper example snippets




use Natedrake\DateHelper\Date;
use Natedrake\DateHelper\DateFormat;

$datePosted=date('2015-08-02 10:36:15');
$date=Date::get()->getDifferenceFromNow($datePosted);


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

$ordinal=Date::ordinal(12);

Date::differenceFromNow($date);

Date::ordinal($number);

DateFormat::get()->date(<date>)-><function>([paramater]);

$isLeapYear=DateFormat::get()->date('2012-01-01')->isLeapYear();

DateFormat::get();

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

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

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

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