PHPackages                             zhusaidong/php-datetime-calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zhusaidong/php-datetime-calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zhusaidong/php-datetime-calculator
==================================

php datetime calculator

09PHP

Since Jun 21Pushed 7y ago1 watchersCompare

[ Source](https://github.com/zhusaidong/php-datetime-calculator)[ Packagist](https://packagist.org/packages/zhusaidong/php-datetime-calculator)[ RSS](/packages/zhusaidong-php-datetime-calculator/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

php-datetime-calculator
=======================

[](#php-datetime-calculator)

php datetime calculator

[![travis](https://camo.githubusercontent.com/1f4da6f3f2a3ccfc0c95a635e8d2e4cd1d2a3f1398ef3fdd834156089f013213/68747470733a2f2f6170692e7472617669732d63692e6f72672f7a6875736169646f6e672f7068702d6461746574696d652d63616c63756c61746f722e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/1f4da6f3f2a3ccfc0c95a635e8d2e4cd1d2a3f1398ef3fdd834156089f013213/68747470733a2f2f6170692e7472617669732d63692e6f72672f7a6875736169646f6e672f7068702d6461746574696d652d63616c63756c61746f722e7376673f6272616e63683d6d6173746572)[![license](https://camo.githubusercontent.com/6e94f14faec4723c4dbaeed7994eaca9e6a48b1c5744cfae1424a7ec37d14805/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7a6875736169646f6e672f7068702d6461746574696d652d63616c63756c61746f722e737667)](https://camo.githubusercontent.com/6e94f14faec4723c4dbaeed7994eaca9e6a48b1c5744cfae1424a7ec37d14805/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7a6875736169646f6e672f7068702d6461746574696d652d63616c63756c61746f722e737667)

Installation
------------

[](#installation)

```
composer require zhusaidong/php-datetime-calculator
```

Usage
-----

[](#usage)

### add or sub time

[](#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

[](#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
-------

[](#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
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c2e985c6870cd488335da55e8b435d590dc8f887ba795af4f818c18b650c888?d=identicon)[zhusaidong](/maintainers/zhusaidong)

---

Top Contributors

[![zhusaidong](https://avatars.githubusercontent.com/u/3039961?v=4)](https://github.com/zhusaidong "zhusaidong (21 commits)")

### Embed Badge

![Health badge](/badges/zhusaidong-php-datetime-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/zhusaidong-php-datetime-calculator/health.svg)](https://phpackages.com/packages/zhusaidong-php-datetime-calculator)
```

###  Alternatives

[workerman/globaldata

8164.2k16](/packages/workerman-globaldata)[silverstripe/html5

HTML5 support for SilverStripe

16232.6k4](/packages/silverstripe-html5)[kunstmaan/utilities-bundle

The KunstmaanUtilitiesBundle makes your life easier by providing a couple of small but usefull helper services you can use and re-use in your applications. We already implemented an easy to use cipher service and a shell helper service for you but feel free to send in a pull request with your additions. The shell helper allows you to run apps in the background, see if a process is running and has a method to kill a running process. The cipher service allow you to encode and decode strings using the Rijndael 256 cipher

13150.5k6](/packages/kunstmaan-utilities-bundle)[uestla/twigrid

Experimental DataGrid for Nette Framework

1712.3k2](/packages/uestla-twigrid)[miladrahimi/php-enum

A PHP Abstract Enum Class

1113.0k](/packages/miladrahimi-php-enum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
