library php-datetime-calculator
php datetime calculator
zhusaidong/php-datetime-calculator
php datetime calculator
- Thursday, June 21, 2018
- by zhusaidong
- Repository
- 1 Watchers
- 0 Stars
- 3 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
php-datetime-calculator
php datetime calculator, (*1)
, (*2)
Installation
composer require zhusaidong/php-datetime-calculator
Usage
add or sub time
require('./vendor/autoload.php');
use \zhusaidong\DateTimeCalculator\DateTimeCalculator;
$dtc = new DateTimeCalculator;
$dtc->setTimestamp(time());
echo $dtc->sub(DateTimeCalculator::YEAR,1)->add(DateTimeCalculator::MONTH,1)->format();
//output:2017-07-16 17:36:51
time diff
require('./vendor/autoload.php');
use \zhusaidong\DateTimeCalculator\DateTimeCalculator;
$dtc = new DateTimeCalculator;
$dtc->setTimestamp(time());
echo $dtc->add(DateTimeCalculator::YEAR,1)->diff(DateTimeCalculator::now());
//output:365
methods
format();//format date
diff();//diff date
add();//add date
sub();//sub date
next();//next date
last();//last date
ago();//this function is an alias of sub