PHPackages                             kibatic/timezone-bundle - 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. kibatic/timezone-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

kibatic/timezone-bundle
=======================

Used to manage the display of a \\DateTimeInterface in the right timezone.

v2.3.0(10mo ago)0481MITPHPPHP ^7.2|^8.0

Since Oct 11Pushed 10mo ago2 watchersCompare

[ Source](https://github.com/kibatic/KibaticTimezoneBundle)[ Packagist](https://packagist.org/packages/kibatic/timezone-bundle)[ RSS](/packages/kibatic-timezone-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (11)Versions (15)Used By (0)

Kibatic Timezone Bundle
=======================

[](#kibatic-timezone-bundle)

[![Build Status](https://camo.githubusercontent.com/8c31d84abe56f282174bc960f894a1cb76e8284d1d18bc834aaee40a7e314762/68747470733a2f2f7472617669732d63692e636f6d2f6b6962617469632f4b69626174696354696d657a6f6e6542756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/kibatic/KibaticTimezoneBundle)

This bundle is used to manage the display of a \\DateTimeInterface in the right timezone.

The common case is a project with all the \\DateTimeInterface objects are in UTC (in the DB, in PHP, ...) but the user can change the timezone in his preferences in order to display the dates with its own timezone.

Quick start
-----------

[](#quick-start)

installation

```
composer require kibatic/timezone-bundle
```

in config.yml

```
kibatic_timezone:
    default_display_timezone: "Europe/Paris"    # mandatory
    timezone_provider: "App\\Timezone\\MyTimezoneProvider"   # optional
```

in php

```
/** @var \DateTimeInterface $date */
$date = new \DateTimeImmutable();

$tzAdjuster = $container->get('kibatic_timezone.adjuster');
$dateTimeImmutable = $tzAdjuster->asDateTimeImmutable($date);
$dateTime = $tzAdjuster->asDateTime($date);
```

Convert \\DateTime to a given timezone with AdjusterUtil
--------------------------------------------------------

[](#convert-datetime-to-a-given-timezone-with-adjusterutil)

```
$date = new \DateTime('2019-10-03T15:28:06.256+02:00');
$dateModified = AdjusterUtil::changeTimezone($date, new \DateTimeZone('GMT+0'));
```

Format datetime with timezone in twig
-------------------------------------

[](#format-datetime-with-timezone-in-twig)

in twig the syntax of tzdate is exactly the same as the [twig date filter](https://twig.symfony.com/doc/2.x/filters/date.html). (it calls the default date filter. The only difference is that the timezone argument is set to false by default)

```
{{ date | tzdate }}
{{ date | tzdate('Y/m/d') }}
```

Format Datetime in twig with localization (intl)
------------------------------------------------

[](#format-datetime-in-twig-with-localization-intl)

You can use the new twig : tz\_format\_datetime filter. It has the same interface than the [format\_datetime filter from twig/extra-bundle](https://twig.symfony.com/doc/3.x/filters/format_datetime.html), but with a $timezone to false by default.

```
{{ date | tz_format_datetime('short', 'short') }}
{{ date | tz_format_datetime('long', 'long') }}
{{ date | tz_format_datetime }}
```

Deprecated Localized date
-------------------------

[](#deprecated-localized-date)

You can use the new twig : tzlocalizeddate filter. It has the same interface than the [localizeddate filter from twig-extension intl](https://twig-extensions.readthedocs.io/en/latest/intl.html#localizeddate), but with a $timezone to false by default.

```
{{ date | tzlocalizeddate('short', 'short') }}
{{ date | tzlocalizeddate('long', 'long') }}
{{ date | tzlocalizeddate }}
```

Timezone Provider
-----------------

[](#timezone-provider)

A timezone Provider is a service that implements TimezoneProviderInterface.

It's a service that is used to know the current timezone to display (for a webpage, an API, in a command, for an export,...)

It implements [TimezoneProviderInterface](Provider/TimezoneProviderInterface)

The adjuster as twig global variable
------------------------------------

[](#the-adjuster-as-twig-global-variable)

If needed, you can add the adjuster as a twig global variable :

in config/packages/twig.yaml, you can add

```
twig:
  globals:
    timezoneAdjuster: '@kibatic_timezone.adjuster'
```

and then in any twig you can use the adjuster

```
Timezone : {{ timezoneAdjuster.displayTimezone().name }}

{# convertir un datetime en datetime avec la bone timezone #}
{{ timezoneAdjuster.asDateTime(date) }}
```

Versions
--------

[](#versions)

2020-10-16 : v2.1.0

- NEW : refactoring : add a AdjusterUtil class that allows to convert datetimes without instanciating Adjuster service
- FIX : microsecond management. The last library removed microseconds from datetime.

2020-10-16 : v2.0.0

MAJOR BC BREAKS !!

- symfony 5.1+ only
- Twig 3+
- twig/extra-bundle instead of twig/extensions
- tzlocalizeddate is deprecated. Use tz\_format\_datetime instead

2019-10-14 : v1.1.1

- hum... fix unit tests in travis for v1.1.0

2019-10-14 : v1.1.0

- Readme updated
- add tzlocalizeddate twig filter

2019-10-11 : v1.0.2

- only for sf4.3+

2019-10-11 : v1.0.1

- fix deprecation in Configurator for sf4

2019-10-11 : v1.0.0

- initial publication

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance54

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 80.8% 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 ~175 days

Recently: every ~284 days

Total

13

Last Release

312d ago

Major Versions

v1.1.1 → v2.0.02020-10-16

v1.1.2 → v2.2.02023-06-12

PHP version history (4 changes)v1.0.0PHP ^7.1

v2.0.0PHP ^7.2

v2.1.1PHP ^7.2|^8.0

v1.x-devPHP ^7.1 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/95c1423b83010cc8afd1fc966d26cc6fc5d7fb5d000e5d7582adcd8392bd239c?d=identicon)[kitpages](/maintainers/kitpages)

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

---

Top Contributors

[![philippe-levan](https://avatars.githubusercontent.com/u/393066?v=4)](https://github.com/philippe-levan "philippe-levan (21 commits)")[![jcrombez](https://avatars.githubusercontent.com/u/777666?v=4)](https://github.com/jcrombez "jcrombez (5 commits)")

---

Tags

datetimetimezone

### Embed Badge

![Health badge](/badges/kibatic-timezone-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kibatic-timezone-bundle/health.svg)](https://phpackages.com/packages/kibatic-timezone-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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