PHPackages                             kveugene/datetime - 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. kveugene/datetime

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

kveugene/datetime
=================

Date and time additional library

1.0.0(4w ago)01MITPHPPHP ^8.4CI passing

Since May 11Pushed 4w agoCompare

[ Source](https://github.com/KVEugene/datetime)[ Packagist](https://packagist.org/packages/kveugene/datetime)[ RSS](/packages/kveugene-datetime/feed)WikiDiscussions master Synced 1w ago

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

PHP DateTime and DateInterval Extension
=======================================

[](#php-datetime-and-dateinterval-extension)

[![PHPUnit Tests](https://github.com/KVEugene/datetime/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/KVEugene/datetime/actions/workflows/phpunit.yml)[![Coverage](https://raw.githubusercontent.com/KVEugene/datetime/image-data/coverage.svg)](https://github.com/KVEugene/datetime/blob/image-data/coverage.svg)[![License: MIT](https://camo.githubusercontent.com/eec5a24cedad3103fcb3aa537c42a677a817a0eb372903ec0a8a6d7d6ff2a9ec/68747470733a2f2f736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d7768697465)](https://camo.githubusercontent.com/eec5a24cedad3103fcb3aa537c42a677a817a0eb372903ec0a8a6d7d6ff2a9ec/68747470733a2f2f736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d7768697465)[![Language: PHP](https://camo.githubusercontent.com/4287e9cb509e6d5e1270bdc81bbbad1291c6b02faddef3bc54f094d37074ab48/68747470733a2f2f736869656c64732e696f2f62616467652f4c616e67756167652d5048502d626c7565)](https://camo.githubusercontent.com/4287e9cb509e6d5e1270bdc81bbbad1291c6b02faddef3bc54f094d37074ab48/68747470733a2f2f736869656c64732e696f2f62616467652f4c616e67756167652d5048502d626c7565)[![Version: >=8.4](https://camo.githubusercontent.com/24535b61c3eef680a9c0a343fb8c08d7e674617be0ed3257a3e12b403104ea5a/68747470733a2f2f736869656c64732e696f2f62616467652f56657273696f6e2d2533453d382e342d626c7565)](https://camo.githubusercontent.com/24535b61c3eef680a9c0a343fb8c08d7e674617be0ed3257a3e12b403104ea5a/68747470733a2f2f736869656c64732e696f2f62616467652f56657273696f6e2d2533453d382e342d626c7565)

Information
-----------

[](#information)

This solution is designed to simplify the definition of time range boundaries in both sliding and calendar window modes.

The sliding window mode involves deriving the start and end of a time range relative to the current date and time, specified in seconds, minutes, hours, days, weeks, months, quarters, or years. This mode is implemented using the standard `DateInterval` mechanism.

The calendar window mode involves defining the start and end points of a specific time range relative to the calendar. In other words, a calendar window allows you to determine the beginning and end of the current, previous, or next day, week, month, quarter, etc.

The operating mode is determined based on whether a time zone is specified. Specifically, if a time zone is designated for a given interval, values ​​are calculated according to the calendar; otherwise, calculations are performed based on a sliding time window.

Requirements
------------

[](#requirements)

This library works only with PHP version 8.4 and higher.

Extension mb-string is required.

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

[](#installation)

You can install the library using Composer:

```
composer install kveugene/datetime
```

Usage
-----

[](#usage)

### DateTime

[](#datetime)

Syntactic Sugar for Date and Time.

```
use KVEugene\DateTime\DateTime;

// Extracts the hour from a natively DateTime object.
$date = new \DateTime();
$hour = (int) $date->format('H');

// Extracts the hour from a library DateTime object.
$date = new DateTime();
$hour = $date->hour;

// Sets the date to the first day of the month (natively)
$date = new \DateTime();
$date->setDate((int) $date->format('Y'), (int) $date->format('n'), 1);

// Sets the date to the first day of the month using a library.
$date = new DateTime();
$date->day = 1;
```

### TimeOffset

[](#timeoffset)

The TimeOffset object is an extension of the native DateInterval object, enabling the use of calendar-based date and time definitions.

```
use KVEugene\DateTime\DateTime;
use KVEugene\DateTime\TimeOffset;

// Get the start date and time of the quarter: sliding mode.
$date = new DateTime()->sub(new TimeOffset('1q'));

// Get the start date and time of the current quarter in the Europe/Riga time zone.
$date = new DateTime()->sub(new TimeOffset('1q Europe/Riga'));

// Get the start date and time of the previous quarter in the Europe/Riga time zone.
$date = new DateTime()->sub(new TimeOffset('2q Europe/Riga'));
```

You can obtain additional information about available properties and formats from the source code documentation.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance94

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

29d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc93f2bcadad77ed6f4ad926faa5794234074cee5aa98e11ba08f64a01d86ff1?d=identicon)[KVEugene](/maintainers/KVEugene)

---

Top Contributors

[![KVEugene](https://avatars.githubusercontent.com/u/125981570?v=4)](https://github.com/KVEugene "KVEugene (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kveugene-datetime/health.svg)

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

###  Alternatives

[gdmedia/ss-auto-git-ignore

A Composer post-update-cmd script to automatically add Composer managed SilverStripe modules and themes to .gitignore

26223.9k6](/packages/gdmedia-ss-auto-git-ignore)[super-eggs/dcat-distpicker

Distpicker extension for dcat-admin

8012.2k](/packages/super-eggs-dcat-distpicker)

PHPackages © 2026

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