PHPackages                             neunerlei/tiny-timy - 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. neunerlei/tiny-timy

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

neunerlei/tiny-timy
===================

\[DEPRECATED\]: use 'nesbot/carbon' instead! A tiny (150 lines without comments) extension for the native DateTime object

1.3.0(3mo ago)02.0k1Apache-2.0ShellPHP &gt;=7.3CI failing

Since Mar 13Pushed 3mo agoCompare

[ Source](https://github.com/Neunerlei/tiny-timy)[ Packagist](https://packagist.org/packages/neunerlei/tiny-timy)[ RSS](/packages/neunerlei-tiny-timy/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (1)Versions (9)Used By (1)

\[DEPRECATED\] Tiny Timy - DateTimy
===================================

[](#deprecated-tiny-timy---datetimy)

Warning

I have migrated away from this package to [Carbon](https://carbon.nesbot.com/docs/). Autoloading PHP classes made Carbon a much more viable option even for small use cases. If you need to migrate from Tiny Timy to carbon, please take a look at the [migration guide](MIGRATION.md) I created to help you with the process. The best of luck and thank you for using Tiny Timy in the past :D

There are a lot of really powerful date and time libraries out there ([carbon](https://carbon.nesbot.com/docs/), [chronos](https://github.com/cakephp/chronos), ...) that are valid if you have to do a lot of date-related actions. For the most part of my daily work I just need date formatting and correct timezone handling. Using huge classes with thousands of lines of code for formatting a date time object always felt wrong.

That's why there is tiny DateTimy, it's a tiny (150 lines without comments) extension for the native DateTime object and therefore 100% compatible with it.

It brings common formats (sql, javascript, rss...), translated time formats (using LOCALE), a more resilient constructor and "automatic" timezone conversion.

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

[](#installation)

Install this package using composer:

```
composer require neunerlei/tiny-timy

```

#### Usage

[](#usage)

You can use the DateTimy class in exactly the same way you would work with a DateTime object.

```
use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy();
$date = new DateTimy("now");
```

Features
--------

[](#features)

### Timezone conversion

[](#timezone-conversion)

The concept of timezone conversion is build on the assumption that you have (for the most part) two different main timezones you work with. a.) the timezone of your server (in my reality UTC for the most part) and b.) the timezone of the client when you render a time for the end user.

So by default all new instances of the DateTimy class will be set to the "server" timezone which is UTC. The given $time given to the constructor is also assumed to be in the "server" timezone until you provide another timezone manually.

If you want to convert the timezone to your client's needs you can use the "toClient()" method. By default, the "client" timezone is defined by date\_default\_timezone\_get() until you manually change it.

To configure the timezones you can use the static configureTimezone() method to set both timezones to your needs.

```
use Neunerlei\TinyTimy\DateTimy;

// Set the client timezone
DateTimy::configureTimezone("Europe/London");
// Set the server timezone
DateTimy::configureTimezone("Europe/Moscow", true);

// New created instances ar now per default in the "Europe/Moscow" timezone
$i = new DateTimy();
$i->getTimezone()->getName(); // "Europe/Moscow"

// Convert it to the client timezone
$i->toClientTimezone()->getTimezone()->getName(); // "Europe/London"

// And back to the server timezone
$i->toServerTimezone()->getTimezone()->getName(); // "Europe/Moscow"
```

### Extended constructor

[](#extended-constructor)

The constructor of the DateTimy class was extended to handle different time options more reliable than the default constructor would.

##### Numeric values

[](#numeric-values)

Numeric values will automatically be parsed as timestamp, so no need to put an "@" in front of it.

```
use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy(time() + 400);
```

##### Cloning / Transforming Datetime objects

[](#cloning--transforming-datetime-objects)

You can pass an instance of a DateTime() or DateTimy() class as $time. The constructor will handle the conversion for you

```
use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy(new DateTimy());
$date = new DateTimy(new DateTime());
```

##### Timezone from string

[](#timezone-from-string)

The constructor can now handle timezones based on a string as well as the default DateTimeZone() objects.

```
use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy("now", "Europe/Berlin");
```

##### Using a format

[](#using-a-format)

While using createFromFormat() to create a new instance based on a string that follows a non-standard format is still possible, the constructor now has the capability to read a string from a format as well.

```
use Neunerlei\TinyTimy\DateTimy;
$date = new DateTimy("2020.03.13 00:00", null, "Y.m.d H:i");

// You can use registered formats as well
$date = new DateTimy("2020.03.13 00:00", null, DateTimy::FORMAT_TYPE_DATE_AND_TIME);
```

#### Common Formats

[](#common-formats)

I am a lazy person when it comes to work I have to do repeatedly. Date / Time Formats in PHP is such a task. Therefore the class provides you with some preconfigured formats and the option to change them or to create completely new ones. The default formats included are:

- date =&gt; Y.m.d
- time =&gt; H:i
- dateAndTime =&gt; Y.m.d H:i
- sql =&gt; Y-m-d H:i:s
- sqlDate =&gt; Y-m-d
- js =&gt; D M d Y H:i:s O
- rss =&gt; D, d M Y H:i:s T

All formats can be applied using the "format" method, or by using the magic method that brings support for every registered format like: formatDateAndTime()

```
use Neunerlei\TinyTimy\DateTimy;
$i = new DateTimy();
$i->format(DateTimy::FORMAT_TYPE_DATE);
// or
$i->formatDateAndTime();
// or
$i->format("dateAndTime");
```

You can add a new format or modify preconfigured formats using the configureFormat() method.

```
use Neunerlei\TinyTimy\DateTimy;
// Editing an existing format
DateTimy::configureFormat(DateTimy::FORMAT_TYPE_DATE, "d.m.Y");
// Add your own format
DateTimy::configureFormat("specialFormat", "d-m-Y");
```

After you added your own format you can use it like any preconfigured format like:

```
use Neunerlei\TinyTimy\DateTimy;
// Create from your special format
$i = new DateTimy("...", null, "specialFormat");
// Print your special format with
$i->formatSpecialFormat();
// or
$i->format("specialFormat");
```

#### Localized formatting

[](#localized-formatting)

By default php only translates your time formats for month or weekday names only when you use the strftime() method. This is not supported for DateTime objects and requires its own special syntax (I forget the chars every time...).

For that the DateTimy class provides you with the formatLocalized() method. It translates F, l, M or D based on your current LOCALE exactly like strftime() would **while keeping the same syntax as format() does**!

```
use Neunerlei\TinyTimy\DateTimy;
// LOCALE de_DE.UTF8
$i = new DateTimy();
$i->formatLocalized("D"); // Montag
```

Running tests
-------------

[](#running-tests)

- Clone the repository
- Install the dependencies with `composer install`
- Run the tests with `composer test`

Special Thanks
--------------

[](#special-thanks)

Special thanks goes to the folks at [LABOR.digital](https://labor.digital/) (which is the word german for laboratory and not the english "work" :D) for making it possible to publish my code online.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment I highly appreciate you sending me a postcard from your hometown, mentioning which of our package(s) you are using.

You can find my address [here](https://www.neunerlei.eu/).

Thank you :D

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance82

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

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

Recently: every ~194 days

Total

7

Last Release

94d ago

PHP version history (3 changes)1.1.0PHP ^7.3

1.2.0PHP &gt;=7.3 &lt;8.4

1.3.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0eb1c26fb5a535cd7a656faffbae7929009558b2bfa6156b2be7b636d689e13a?d=identicon)[labor-digital](/maintainers/labor-digital)

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

---

Top Contributors

[![Neunerlei](https://avatars.githubusercontent.com/u/22350956?v=4)](https://github.com/Neunerlei "Neunerlei (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/neunerlei-tiny-timy/health.svg)

```
[![Health](https://phpackages.com/badges/neunerlei-tiny-timy/health.svg)](https://phpackages.com/packages/neunerlei-tiny-timy)
```

PHPackages © 2026

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