PHPackages                             cse/helpers-date - 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. [Framework](/categories/framework)
4. /
5. cse/helpers-date

ActiveLibrary[Framework](/categories/framework)

cse/helpers-date
================

The helpers allows you to easy use DATE. Change format, add/sub day, diff date, get quarter - all this is available in this library.

1.0.5(7y ago)595321MITPHPPHP &gt;=7.1

Since Feb 10Pushed 7y ago3 watchersCompare

[ Source](https://github.com/cs-eliseev/helpers-date)[ Packagist](https://packagist.org/packages/cse/helpers-date)[ Docs](https://github.com/cs-eliseev/helpers-date)[ RSS](/packages/cse-helpers-date/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (7)Used By (1)

English | [Русский](https://github.com/cs-eliseev/helpers-date/blob/master/README.ru_RU.md)

DATE CSE HELPERS
================

[](#date-cse-helpers)

[![Travis (.org)](https://camo.githubusercontent.com/410b7ae7019e25d1cf89e9d37d715b85f5920768f25e9f23ec5dfb72126bfeff/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63732d656c69736565762f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/cs-eliseev/helpers-date)[![Codecov](https://camo.githubusercontent.com/041bf0a2b5584c80bb5699a62177a2b2adc38a7e7d4fd79bf34b4ee076c26c11/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f63732d656c69736565762f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/cs-eliseev/helpers-date)[![Scrutinizer code quality](https://camo.githubusercontent.com/c2018c279f43f1c44e122da92a0a0c509c033f0867214d5ab9ee92c7f25cc206/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f63732d656c69736565762f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cs-eliseev/helpers-date/?branch=master)

[![Packagist](https://camo.githubusercontent.com/245ce150f2ab9756538d217b6264d14453f2ad2fc5acfab4c0e349574a004aa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6373652f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cse/helpers-date)[![Minimum PHP Version](https://camo.githubusercontent.com/dcd4b4aec2c1709157fa6a2c050f709d75cde9552a79cfff0b70a97fad7281ae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e312d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cse/helpers-date)[![Packagist](https://camo.githubusercontent.com/05c8f8d7f862704f3572309f159862a8874de5c207a0c5d3aee607b1be62d055/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6373652f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/cs-eliseev/helpers-date/blob/master/LICENSE.md)[![GitHub repo size](https://camo.githubusercontent.com/346d85eda184f3ed240fffa5541a45fa2c70d7e8ea544f8b1efd34af4375f173/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f63732d656c69736565762f68656c706572732d646174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/cs-eliseev/helpers-date/archive/master.zip)

The helpers allows you to easy use DATE. Change format, add/sub day, diff date, get quarter - all this is available in this library.

Project repository:

**DATE**

```
if (Date::isToday($date)) {
    $date = Date::changeDay($date, -7);
}
$mount = Date::diff($date, 'now', '%m');
Date::getQuarterByNumberMonth($mount);
```

---

Introduction
------------

[](#introduction)

[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) is a collection of several libraries with simple functions written in PHP for people.

Despite using PHP as the main programming language for the Internet, its functions are not enough. DATE CSE HELPERS used method: change format, add/sub day, diff date, get quarter and other.

[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) was created for the rapid development of web applications.

**CSE Helpers project:**

- [Array CSE helpers](https://github.com/cs-eliseev/helpers-arrays)
- [Cookie CSE helpers](https://github.com/cs-eliseev/helpers-cookie)
- [Date CSE helpers](https://github.com/cs-eliseev/helpers-date)
- [Email CSE helpers](https://github.com/cs-eliseev/helpers-email)
- [IP CSE helpers](https://github.com/cs-eliseev/helpers-ip)
- [Json CSE helpers](https://github.com/cs-eliseev/helpers-json)
- [Math Converter CSE helpers](https://github.com/cs-eliseev/helpers-math-converter)
- [Phone CSE helpers](https://github.com/cs-eliseev/helpers-phone)
- [Request CSE helpers](https://github.com/cs-eliseev/helpers-request)
- [Session CSE helpers](https://github.com/cs-eliseev/helpers-session)
- [Word CSE helpers](https://github.com/cs-eliseev/helpers-word)

Below you will find some information on how to init library and perform common commands.

Install
-------

[](#install)

You can find the most recent version of this project [here](https://github.com/cs-eliseev/helpers-date).

### Composer

[](#composer)

Execute the following command to get the latest version of the package:

```
composer require cse/helpers-date
```

Or file composer.json should include the following contents:

```
{
    "require": {
        "cse/helpers-date": "*"
    }
}
```

### Git

[](#git)

Clone this repository locally:

```
git clone https://github.com/cs-eliseev/helpers-date.git
```

### Download

[](#download)

[Download the latest release here](https://github.com/cs-eliseev/helpers-date/archive/master.zip).

Usage
-----

[](#usage)

The class consists of static methods that are conveniently used in any project. See example [examples-date.php](https://github.com/cs-eliseev/helpers-date/blob/master/examples/examples-date.php).

**GET time by date**

Example:

```
Date::getTime('01.01.2018');
// 1514754000
```

Use current date:

```
Date::getTime();
Date::getTime('now');
// timestemp
```

Use relative time:

```
Date::getTime('+1 week 2 days 4 hours 2 seconds');
// timestemp
```

**Convert date to format**

Example:

```
Date::toFormat('2018-01-01');
// 01.01.2018
```

Use timestamp:

```
Date::toFormat(1514754000);
// 01.01.2018
```

Change default format:

```
Date::toFormat(1514754000, 'Y/m/d');
// 2018/01/01
```

Use current date:

```
Date::toFormat();
Date::toFormat('now');
// d.m.Y
```

Use relative time:

```
Date::toFormat('+1 week 2 days 4 hours 2 seconds');
```

**Convert date to SQL**

Example:

```
Date::toSQL('01.01.2018');
// 2018-01-01
```

Use timestamp:

```
Date::toSQL(1514754000);
// 2018-01-01
```

Use current date:

```
Date::toSQL();
Date::toSQL('now');
// Y-m-d
```

Use relative time:

```
Date::toSQL('+1 week 2 days 4 hours 2 seconds');
// Y-m-d
```

**Diff date**

Example:

```
Date::diff('2018-07-01', '2018-07-01');
// 0
```

Date format hour:

```
Date::diff('2018-07-01 02:00:00', '01.01.2018 00:00:00', '%h');
// 2
```

Use timestamp:

```
Date::diff(strtotime('2018-09-02'), strtotime('2018-07-02'), '%m'));
// 2
```

Other format:

```
Date::diff('31.01.2018', 1514754000, '%d/%m'));
// 30/0
```

Current date:

```
Date::diff('31.01.2018');
Date::diff('31.01.2018', 'now');
// %d
```

Use relative time:

```
Date::diff'31.01.2018', '+1 week');
// %d
```

**Current date**

Example:

```
Date::current();
// d.m.Y
```

Set format:

```
Date::current(Date::FORMAT_SQL);
// Y-m-d
```

**Extreme month date**

Get last day month:

```
Date::extremeMonthDate('11.01.2018');
// 2018-01-31
```

Get first day month:

```
Date::extremeMonthDate('28.02.2018', 'Y-m-01');
// 2018-02-01
```

Use timestemp:

```
Date::extremeMonthDate(strtotime('28.02.2018'), 'Y-m-01');
// 2018-02-01
```

Use current date:

```
Date::extremeMonthDate();
Date::extremeMonthDate('now');
// Y-m-last_mounth_day
```

Use relative date:

```
Date::extremeMonthDate('+1 week');
// Y-m-last_mounth_day + 1 week
```

**Get quarter**

Example:

```
Date::getQuarter('31.12.2018 23:59:59');
// 4
```

Use timestemp:

```
Date::getQuarter(1514754000);
// 1
```

Use current date:

```
Date::getQuarter();
Date::getQuarter('now');
// quarter
```

Use relative time:

```
Date::getQuarter('+1 week 2 days 4 hours 2 seconds');
// quarter
```

**Get quarter by number month**

Example:

```
Date::getQuarterByNumberMonth(12);
// 4
```

**Change day**

Add day:

```
Date::changeDay('01.01.2018', 1);
// 02.01.2018
```

Sub day:

```
Date::changeDay('2018-01-01', -1);
// 31.12.2017
```

Change format:

```
Date::changeDay('01.01.2018', -1, Date::FORMAT_SQL);
// 2017-12-31
```

Use timestamp:

```
Date::changeDay(timestamp('01.01.2018'), -1, Date::FORMAT_SQL);
// 2017-12-31
```

**Check today**

Example:

```
Date::isToday('01.01.2018 00:00:00');
// false
```

Use timestamp:

```
Date::isToday(1519804800);
// false
```

Use relative time:

```
Date::isToday('now');
// true
```

**Check date**

Example:

```
Date::checkDateByTimestamp((new \DateTime('now'))->format('U'));
// true
```

**SET TIMEZONE**

Example:

```
Date::setTimezone();
// UTC
```

Set timezone:

```
Date::setTimezone('GMT');
// GMT
```

**GET TIMEZONE**

Example:

```
Date::getTimezone();
// UTC
```

**IS TIMEZONE**

Example:

```
Date::isTimezone();
// true
```

Set timezone:

```
Date::isTimezone('GMT');
// false
```

Testing &amp; Code Coverage
---------------------------

[](#testing--code-coverage)

PHPUnit is used for unit testing. Unit tests ensure that class and methods does exactly what it is meant to do.

General PHPUnit documentation can be found at .

To run the PHPUnit unit tests, execute:

```
phpunit PATH/TO/PROJECT/tests/
```

If you want code coverage reports, use the following:

```
phpunit --coverage-html ./report PATH/TO/PROJECT/tests/
```

Used PHPUnit default config:

```
phpunit --configuration PATH/TO/PROJECT/phpunit.xml
```

Donating
--------

[](#donating)

You can support this project [here](https://www.paypal.me/cseliseev/10usd). You can also help out by contributing to the project, or reporting bugs. Even voicing your suggestions for features is great. Anything to help is much appreciated.

License
-------

[](#license)

The DATE CSE HELPERS is open-source PHP library licensed under the MIT license. Please see [License File](https://github.com/cs-eliseev/helpers-date/blob/master/LICENSE.md) for more information.

---

> GitHub [@cs-eliseev](https://github.com/cs-eliseev)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~16 days

Total

6

Last Release

2612d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3b9e49d0ce3fd71c8eb31b7c14e48373dbb415a9d16950ce52d23bf89b2ae26?d=identicon)[ak\_eliseev](/maintainers/ak_eliseev)

---

Top Contributors

[![cs-eliseev](https://avatars.githubusercontent.com/u/24221291?v=4)](https://github.com/cs-eliseev "cs-eliseev (104 commits)")

---

Tags

collectioncollectionsconvertercsedateframeworkhelperhelperslibraryphptooltoolsutilitiesutilityutilsframeworkhelperutilityhelperslibrarytoolconverterdatecollectioncollectionsdatestoolsutilsutilitiescse

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cse-helpers-date/health.svg)

```
[![Health](https://phpackages.com/badges/cse-helpers-date/health.svg)](https://phpackages.com/packages/cse-helpers-date)
```

###  Alternatives

[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8161.6M36](/packages/jbzoo-utils)[dragon-code/support

Support package is a collection of helpers and tools for any project.

239.6M106](/packages/dragon-code-support)

PHPackages © 2026

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