library lib-datetime
Code Inc.'s datetime library
codeinchq/lib-datetime
Code Inc.'s datetime library
- Tuesday, February 27, 2018
- by joanfabregat
- Repository
- 1 Watchers
- 0 Stars
- 0 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 0 % Grown
DateTime library
The is just an overlayoer above the native PHP DateTime class with extra methods., (*1)
Usage
<?php
use CodeInc\DateTime\DateTime;
/*
* Can be instantiated with a timestamp (checked with is_numeric())
*/
$dateTime = new DateTime(time());
/*
* Provides methods to tests the current time
*/
$dateTime->isUndefined();
$dateTime->isPast();
$dateTime->isNow();
$dateTime->isFutur();
/*
* Provides methods to get SQL dates
*/
$dateTime->getSqlDate(); // YYYY-MM-DD
$dateTime->getSqlDateTime(); // AAAA-MM-JJ HH:MM:SS
/*
* Provides a method to get a RFC 1123 date
*/
$dateTime->getRfc1123();
/*
* The formats are available in class constants
*/
$dateTime::FORMAT_SQL_DATE;
$dateTime::FORMAT_SQL_DATETIME;
$dateTime::FORMAT_RFC_1123;
Installation
This library is available through Packagist and can be installed using Composer:, (*2)
composer require codeinc/datetime
License
The library is published under the MIT license (see LICENSE file)., (*3)