PHPackages                             marsapp/datetimehelper - 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. marsapp/datetimehelper

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

marsapp/datetimehelper
======================

DatetimeHelper library, providing format judgment, time increase and decrease, etc.

0.1.0(7y ago)272MITPHP

Since Mar 28Pushed 7y agoCompare

[ Source](https://github.com/marshung24/DatetimeHelper)[ Packagist](https://packagist.org/packages/marsapp/datetimehelper)[ Docs](https://github.com/marshung24/DatetimeHelper)[ RSS](/packages/marsapp-datetimehelper/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

DatetimeHelper
==============

[](#datetimehelper)

Time processing library, providing format judgment, time increase and decrease, etc.

> Continuation library marshung/helper, only keep and maintain DatetimeHelper

[![Latest Stable Version](https://camo.githubusercontent.com/fb23f020d0db4d0dbd3af8983c306cb5243be87c86adea85ef4cdd7bd3e8f5ff/68747470733a2f2f706f7365722e707567782e6f72672f6d6172736170702f6461746574696d6568656c7065722f762f737461626c65)](https://packagist.org/packages/marsapp/datetimehelper) [![Total Downloads](https://camo.githubusercontent.com/f1df796b95084fc5b6429b00a73c5c7ea710bfc221bdf40bc6dd9afd1cb281d1/68747470733a2f2f706f7365722e707567782e6f72672f6d6172736170702f6461746574696d6568656c7065722f646f776e6c6f616473)](https://packagist.org/packages/marsapp/datetimehelper) [![Latest Unstable Version](https://camo.githubusercontent.com/83467debd89955188a4fba1c916de2f8556adcaeca0f2c23e040b3201789f9c4/68747470733a2f2f706f7365722e707567782e6f72672f6d6172736170702f6461746574696d6568656c7065722f762f756e737461626c65)](https://packagist.org/packages/marsapp/datetimehelper) [![License](https://camo.githubusercontent.com/ff7649abb962c5d1ce384c4e6e34e5b436c0488e6d0ec957bd4ebf0e801ee33b/68747470733a2f2f706f7365722e707567782e6f72672f6d6172736170702f6461746574696d6568656c7065722f6c6963656e7365)](https://packagist.org/packages/marsapp/datetimehelper)

Outline
=======

[](#outline)

- [Installation](#Installation)
- [Usage](#Usage)
    - [DatetimeHelper](#DatetimeHelper)

[Installation](#Outline)
========================

[](#installation)

Composer Install
----------------

[](#composer-install)

```
# composer require marsapp/datetimehelper

```

Include
-------

[](#include)

Include composer autoloader before use.

```
require __PATH__ . "vendor/autoload.php";
```

[Usage](#Outline)
=================

[](#usage)

[DatetimeHelper](#Outline)
--------------------------

[](#datetimehelper-1)

Namespace use:

```
use marsapp\helper\datetime\DatetimeHelper;
```

### isDate()

[](#isdate)

Determine if the date is legal

```
isDate($date) : Bool
```

Example :

```
if (DatetimeHelper::isDate('2019-01-15)) {
	die('Date format error');
}
```

### dateAdd()

[](#dateadd)

Date calculation - increase

```
dateAdd(String $date, Int $add = '1', String $unit = 'day', String $format = 'Y-m-d') : string
```

> $unit: day, month, year, hour, minute, second

Example :

```
DatetimeHelper::dateAdd('2019-01-31', '1', 'day');
// result: 2019-02-01

DatetimeHelper::dateAdd('2019-01-31', '1', 'month');
// result: 2019-02-28

DatetimeHelper::dateAdd('2019-01-31 12:34:56', '13', 'month', 'Y-m-d H:i:s');
// result: 2020-02-29 12:34:56

DatetimeHelper::dateAdd('2019-01-31 12:34:56', '20', 'hour', 'Y-m-d H:00:00');
// result: 2019-02-01 09:00:00
```

### dateReduce()

[](#datereduce)

Date calculation - reduction

```
dateReduce(String $date, Int $reduce = '1', String $unit = 'day', String $format = 'Y-m-d') : string
```

> $unit: day, month, year, hour, minute, second

Example :

```
DatetimeHelper::dateReduce('2019-01-01', '1', 'day');
// result: 2018-12-31

DatetimeHelper::dateReduce('2019-01-31', '2', 'month');
// result: 2018-11-30

DatetimeHelper::dateReduce('2020-02-29 12:34:56', '1', 'year', 'Y-m-d H:i:s');
// result: 2019-02-28 12:34:56
```

### dateCal()

[](#datecal)

Date calculation

```
dateCal(String $date, Int $difference = '1', String $unit = 'day', String $format = 'Y-m-d') : string
```

> $difference positive is add, negative is reduce
> $unit: day, month, year, hour, minute, second

Example :

```
DatetimeHelper::dateCal('2019-01-31', '1', 'month');
// result: 2019-02-28

DatetimeHelper::dateCal('2020-02-29', '-1', 'year');
// result: 2019-02-28
```

### dateIterator()

[](#dateiterator)

Get Date Iterator - Iteration Date in Days

```
dateIterator($startDate, $endDate)
```

Example :

```
$daterange = DateTimeHelper::dateIterator('2018-01-01', '2018-01-31');
foreach($daterange as $date){
    echo $date->format('Y-m-d') . '';
}
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2650d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34496839?v=4)[MarsHung](/maintainers/marshung24)[@marshung24](https://github.com/marshung24)

---

Top Contributors

[![marshung24](https://avatars.githubusercontent.com/u/34496839?v=4)](https://github.com/marshung24 "marshung24 (14 commits)")

### Embed Badge

![Health badge](/badges/marsapp-datetimehelper/health.svg)

```
[![Health](https://phpackages.com/badges/marsapp-datetimehelper/health.svg)](https://phpackages.com/packages/marsapp-datetimehelper)
```

###  Alternatives

[fojuth/readmegen

Readme file / doc generator. It uses VCS logs as a source of information.

6238.0k1](/packages/fojuth-readmegen)[webcraft/laravel-random

Laravel wrapper around paragonie/random-lib

1011.1k](/packages/webcraft-laravel-random)[lingxi/hashids

A Hashids bridge for Laravel

183.3k](/packages/lingxi-hashids)

PHPackages © 2026

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