PHPackages                             twipsi/chronos - 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. twipsi/chronos

ActiveLibrary

twipsi/chronos
==============

Provides a simplified interface to play with time

1.0.0(3y ago)041BSD-3-ClausePHPPHP &gt;=8.1

Since Oct 27Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Twipsi/chronos)[ Packagist](https://packagist.org/packages/twipsi/chronos)[ Docs](http://www.github.com/twipsi/chronos)[ RSS](/packages/twipsi-chronos/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Chronos
=======

[](#chronos)

Simple class to play with time

Install
-------

[](#install)

```
composer require twipsi/chronos

```

Initializing the class
----------------------

[](#initializing-the-class)

You can set the initial date as a DateTime object or a Chronos instance or a valid date string or a timestamp.

```
Chronos::date(new Chronos)...
Chronos::date(new DateTime)...
Chronos::date('2022-05-05 10:10:10')...
Chronos::date(1664524279)...

new Chronos(new DateTime)
```

Or just get the current datetime.

```
Chronos::date()...
```

DateTime Options
----------------

[](#datetime-options)

You can specify each option fluently after setting the initial date.

```
Chronos::date($date)
  ->setDateTimeFormat("Y-m-d H:i:s")
  ->setDateFormat("Y-m-d")
  ->setTimeFormat("H:i:s")
  ->setTimezone("UTC")
```

Retrieving the datetime as a string
-----------------------------------

[](#retrieving-the-datetime-as-a-string)

You have multiple methods to retrieve the datetime as a string.

```
 Chronos::date($date)...
     ->getDateObject()
     ->stamp()
     ->getDateTime()
     ->getDate()
     ->getTime()
     ->getHour()
     ->getMinute()
     ->getSeconds()
     ->getDayName()
     ->getDayShortName()
     ->getDayNumber()
     ->getWeekNumber()
     ->getMonthName()
     ->getShortMonthName()
     ->getMonthNumber()
     ->getYear()
```

Manipulating datetime
---------------------

[](#manipulating-datetime)

### Initial methods

[](#initial-methods)

You have several methods to manipulate the initial time before retrieving it as a string.

```
 Chronos::date($date)->addDays()->getDateTime();
 Chronos::date($date)->addMinutes()->getDateTime();
 Chronos::date($date)->addSeconds()->getDateTime();
 Chronos::date($date)->subDays()->getDateTime();
 Chronos::date($date)->subMinutes()->getDateTime();
 Chronos::date($date)->subSeconds()->getDateTime();
```

### Chaining methods

[](#chaining-methods)

You can also chain the methods fluently.

```
 Chronos::date($date)->addDays(40)->addMinutes(1)->subSeconds(20)->getDateTime();
```

Traveling in time
-----------------

[](#traveling-in-time)

### Setting the new datetime

[](#setting-the-new-datetime)

You can set another datetime as a DateTime object or a valid date string or a timestamp to work with intervals.

```
Chronos::date()->travel(new DateTime)...
Chronos::date()->travel('2022-05-05 10:10:10')...
Chronos::date()->travel(1664524279)...
```

### Retrieving the difference

[](#retrieving-the-difference)

You have multiple methods to retrieve the difference as a string.

```
Chronos::date()->travel('2022-05-05 10:10:10')
    ->daysPassed() // This will return 0 if travel date is in the future.
    ->differenceInDays() // This will return negative days if travel is in the past.
    ->hoursPassed()
    ->differenceInHours()
    ->minutesPassed()
    ->differenceInMinutes()
    ->secondsPassed()
    ->differenceInSeconds()
```

You can also do a fast check to see weather we are in the past or future.

```
Chronos::date()->travel('2022-05-05 10:10:10')
   ->isInFuture()
   ->isInPast()
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

1299d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/880200baf15805538d0ea0c5235c033e173768cd401427482c46c650022e7818?d=identicon)[Twipsi](/maintainers/Twipsi)

---

Top Contributors

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

---

Tags

timedateinterval

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/twipsi-chronos/health.svg)

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

###  Alternatives

[league/period

Time range API for PHP

7335.4M21](/packages/league-period)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[brick/date-time

Date and time library

3623.3M61](/packages/brick-date-time)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[azuyalabs/yasumi

The easy PHP Library for calculating holidays

1.1k11.4M26](/packages/azuyalabs-yasumi)[carbonphp/carbon-doctrine-types

Types to use Carbon in Doctrine

213220.4M8](/packages/carbonphp-carbon-doctrine-types)

PHPackages © 2026

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