PHPackages                             buffalokiwi/buffalotools\_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. [Utility &amp; Helpers](/categories/utility)
4. /
5. buffalokiwi/buffalotools\_date

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

buffalokiwi/buffalotools\_date
==============================

Simple date wrapper for PHP 7.4

v1.0.5(4y ago)0191MITPHPPHP ^7.4 || ^8.0

Since Apr 25Pushed 4y ago1 watchersCompare

[ Source](https://github.com/SixArmDonkey/buffalotools_date)[ Packagist](https://packagist.org/packages/buffalokiwi/buffalotools_date)[ Docs](https://github.com/SixArmDonkey/buffalotools_date)[ RSS](/packages/buffalokiwi-buffalotools-date/feed)WikiDiscussions master Synced today

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

BuffaloKiwi Date Wrapper
========================

[](#buffalokiwi-date-wrapper)

This package includes a simple date factory used for converting dates from various formats to instances of DateTimeInterface. and a wrapper for DateTime used for storing UTC and local time in a single object.

MIT License

---

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

[](#installation)

```
composer require buffalokiwi/buffalotools_date

```

---

Overview
--------

[](#overview)

DateFactory is used to create instances of DateTimeInterface and IDateTime. The idea is to pass the local timezone and a list of possible date format strings that will be encountered in some application. Calling createDateTime() with a date string using any of the supplied formats (or formats supported by \\DateTime) will return a valid DateTimeImmutable object or throw an exception.

DateTimeWrapper is used to wrap an instance of DateTimeInterface and provides easy access to both UTC and Local time for a given DateTimeInterface object.

Example
-------

[](#example)

```
$factory = new buffalokiwi\buffalotools\date\DateFactory( 'America/New_York' );

//..createDateTime returns whatever date you pass with the timezone set to whatever zone is supplied.
//..Defaults to UTC.  No time zone conversions occurs within this method.
$utc = $factory->createDateTime( '2021-01-01 12:00:00' );
print_r( $utc );
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 12:00:00.000000
    [timezone_type] => 3
    [timezone] => UTC
)
*/

//..Create a date time but set the time zone to new york.
$local = $factory->createDateTime( '2021-01-01 12:00:00', 'America/New_York' );
print_r( $local );
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 12:00:00.000000
    [timezone_type] => 3
    [timezone] => America/New_York
)
*/

//..createIDateTime is the same as createDateTime, except it always returns the date in UTC.
//  If a non-UTC timezone is passed, the date is converted to UTC.
//  createIDateTime returns instances of IDateTime

//..Create a date time in UTC
$utc = $factory->createIDateTime( '2021-01-01 12:00:00' );
print_r( $utc->getUTC());
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 12:00:00.000000
    [timezone_type] => 3
    [timezone] => UTC
)
*/

print_r( $utc->getLocal());
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 07:00:00.000000
    [timezone_type] => 3
    [timezone] => America/New_York
)
*/

//..Create a local date time.  UTC will be a few hours in the future.
//..Using this method will set getLocal() to the supplied datetime.
$local = $factory->createIDateTime( '2021-01-01 12:00:00', 'America/New_York' );
print_r( $local->getUTC());
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 17:00:00.000000
    [timezone_type] => 3
    [timezone] => UTC
)
*/

print_r( $local->getLocal());
/*
DateTimeImmutable Object
(
    [date] => 2021-01-01 12:00:00.000000
    [timezone_type] => 3
    [timezone] => America/New_York
)
*/
```

The DateFactory has a method now() which can be used to return the current datetime in UTC or relative to UTC.

```
//..Retrieve "now" in UTC
print_r( $factory->now());
/*
DateTimeImmutable Object
(
    [date] => 2021-04-25 16:22:07.073529
    [timezone_type] => 3
    [timezone] => UTC
)
*/

//..Retrieve "now" in some time zone relative to UTC.
//..Converts UTC to the supplied time zone
print_r( $factory->now( 'America/New_York' ));
/*
DateTimeImmutable Object
(
    [date] => 2021-04-25 12:22:07.073529
    [timezone_type] => 3
    [timezone] => America/New_York
)
*/
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

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 ~18 days

Total

6

Last Release

1748d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4.0

v1.0.4PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/26635705c76bff0d1c6b96c4cc92ba9e59a57b7723122ac0c0690f8742310e22?d=identicon)[SixArmDonkey](/maintainers/SixArmDonkey)

---

Top Contributors

[![SixArmDonkey](https://avatars.githubusercontent.com/u/7980059?v=4)](https://github.com/SixArmDonkey "SixArmDonkey (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/buffalokiwi-buffalotools-date/health.svg)

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

###  Alternatives

[alexandresalome/assetic-extra-bundle

Extra feature for Assetic (asset directory)

1811.4k](/packages/alexandresalome-assetic-extra-bundle)

PHPackages © 2026

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