PHPackages                             damenjo/rutin - 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. damenjo/rutin

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

damenjo/rutin
=============

Provide great PHP API Extension for DateTime

1.0.19(2y ago)027MITPHP

Since Aug 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/damenjoSitepu/rutin)[ Packagist](https://packagist.org/packages/damenjo/rutin)[ RSS](/packages/damenjo-rutin/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (21)Used By (0)

Rutin Provide Great PHP API Extension For DateTime Services 👍
-------------------------------------------------------------

[](#rutin-provide-great-php-api-extension-for-datetime-services-1)

### Installation List

[](#installation-list)

You can install this package via:

Dependency ManagerCommand[Composer](https://getcomposer.org/)`composer require damenjo/rutin`### Guidelines

[](#guidelines)

You may get the current date and time just only using our `now()` method. Here's the example below:

```
use Damenjo\Rutin\Main\Rutin;
// 2023-08-03 20:39:45
$now = Rutin::now()->format();
```

By default, our package will recognized this **DateTime** format as `Y-m-d H:i:s` . If you need to define the specific timezone as well, you can set the first argument directly to the `now()` method like this:

```
$now = Rutin::now("Asia/Jakarta")->format();
```

If you need to specified another **DateTime** format, you may also set the first argument for `format()` method. Here's the way to do that:

```
// 2023-08-03
$date = Rutin::now("Asia/Jakarta")->format("Y-m-d");
// 20:39:45
$time = Rutin::now("Asia/Jakarta")->format("H:i:s");
// 2023
$year = Rutin::now("Asia/Jakarta")->format("Y");
```

**Note**: All **DateTime** keyword format was referred to [PHP DateTime Format](https://www.php.net/manual/en/datetime.format.php) documentations.

We also have method that can help you to add or substract `days`, `month`, `year`, etc as many as you want. The list of utilities that you can use will be described below:

Method NameUsed For`addDay()`Add one day to your specific **DateTime**`subDay()`Substract one day to your specific **DateTime**`addDays(int $numberOfDays)`Add **N** days to your specific **DateTime**`addDayIf(callable $prediction)`Add one day to your specific **DateTime** with certain condition`subDayIf(callable $prediction)`Substract one day to your specific **DateTime** with certain condition`addDaysIf(callable $prediction, int $numberOfDays)`Add **N** days to your specific **DateTime** with certain condition`addMonth()`Add one month to your specific **DateTime**`addMonths(int $numberOfMonths)`Add **N** months to your specific **DateTime**`addMonthIf(callable $prediction)`Add one month to your specific **DateTime** with certain condition`addMonthsIf(callable $prediction, int $numberOfMonths)`Add **N** months to your specific **DateTime** with certain condition`addYear()`Add one year to your specific **DateTime**`addYears(int $numberOfYears)`Add **N** years to your specific **DateTime**`addYearIf(callable $prediction)`Add one year to your specific **DateTime** with certain condition`addYearsIf(callable $prediction, int $numberOfYears)`Add **N** years to your specific **DateTime** with certain condition`addTimestamp(int $numberOfTimestamp = 1)`Add defined number of timestamp to your specific **DateTime**`addTimestampIf(callable $prediction, int $numberOfTimestamp = 1)`Add defined number of timestamp to your specific **DateTime** with certain conditionNote

We also now have `add(string $dateElement, int $numberOfDateElement = 1)` or `skip(string $dateElement, int $numberOfDateElement = 1)` to make your life easier. We'll describe the example below the existing code, so please take your time to see it ^\_^

This is a few example how to use all the listed method above:

```
// 2023-08-04
$rutin = Rutin::now()->add("day",1)->format("Y-m-d");

// 2023-08-03
$rutinNow = Rutin::now()->format("Y-m-d");

// 2023-08-04
$rutinPlusOneDay = Rutin::now()->addDay()->format("Y-m-d");

// 2023-08-05
$rutinPlusTwoDay = Rutin::now()->addDays(2)->format("Y-m-d");

// 2023-08-03
$rutinNull = Rutin::now()->addDays(null ?? 0)->format("Y-m-d");
```

Warning

`null` or any type unless `number` will cause an error, so please take a **note** that `try` and `catch` blocks are important to handle the error of your code. For some quick step, lets see this code:

```
try {
    // Invalid argument data type
    $rutinNull = Rutin::now()->addDays("")->format("Y-m-d");
} catch (\Damenjo\Rutin\Exceptions\RutinException $e) {
    // We recommend you to use this catch blocks too
    echo $e->ruinMessage();
} catch (\TypeError $e) {
    // Do whatever you want inside this block
}
```

Also, if you have scenario like to add your day by some conditions, you can use `addDayIf()` .

```
$prediction = true;
$rutinPlusOneDayIf = Rutin::now()->addDayIf(fn() => $prediction)->format("Y-m-d");
```

Certainly, there is a scenario that make you need to use condition within the `add()` method. That is now possible to do with our brand new `while()` .

```
$prediction = true;
Rutin::now()->while(fn() => $prediction)->add("month",3)->format("Y-m-d");
```

Since this method was calling in front of addition or substraction method like `addDay()` or `addMonths()` , `etc` , this awesome `while()` method will determine that addition or substraction functionality will be affected to the current **DateTime** or not.

Warning

`while()` only will affect to addition or substraction datetime method, not another things like `format()`

---

**License**: [MIT](https://opensource.org/license/mit/)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Every ~0 days

Total

20

Last Release

1062d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/88216217?v=4)[Damenjo Sitepu](/maintainers/damenjoSitepu)[@damenjoSitepu](https://github.com/damenjoSitepu)

---

Top Contributors

[![damenjoSitepu](https://avatars.githubusercontent.com/u/88216217?v=4)](https://github.com/damenjoSitepu "damenjoSitepu (73 commits)")

### Embed Badge

![Health badge](/badges/damenjo-rutin/health.svg)

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

###  Alternatives

[algoyounes/circuit-breaker

Circuit Breaker is laravel package that provides a way to handle failures gracefully

584.4k](/packages/algoyounes-circuit-breaker)

PHPackages © 2026

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