PHPackages                             unocha/un\_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. [Templating &amp; Views](/categories/templating)
4. /
5. unocha/un\_date

ActiveDrupal-module[Templating &amp; Views](/categories/templating)

unocha/un\_date
===============

UN date and time twig filters for Drupal 8

2.1.1(1y ago)04.4k↑200%GPL-2.0-onlyPHPPHP &gt;=8.0

Since Jun 3Pushed 1y ago4 watchersCompare

[ Source](https://github.com/UN-OCHA/un_date)[ Packagist](https://packagist.org/packages/unocha/un_date)[ RSS](/packages/unocha-un-date/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (1)Versions (36)Used By (0)

UN Date formatters and twig filters
===================================

[](#un-date-formatters-and-twig-filters)

See [UN standard](https://www.un.org/dgacm/en/content/editorial-manual/numbers-dates-time#dates) for details.

All dates will be outputted as entered, there's no automatic timezone conversion.

We support English, French, Spanish, Chinese and Arabic.

Warning: You need the [patch](https://www.drupal.org/files/issues/2021-12-25/3004425-41.patch)to fix translation of [abbreviated month names](https://www.drupal.org/node/3004425).

The Humand readable output of RRules is flaky.

Install
-------

[](#install)

Run `composer install unocha/un_date`

Core date formatter service
---------------------------

[](#core-date-formatter-service)

This service is replaced by `UnDateFormatter` and will enforce the proper format for `short`, `medium` and `long`.

Formatters
----------

[](#formatters)

There's support for the following

- Core datetime field
- Core datetime\_range field
- Contrib [daterange\_timezone](https://www.drupal.org/project/datetime_range_timezone)
- Contrib [date\_recur](https://www.drupal.org/project/date_recur)

Twig filters and functions
--------------------------

[](#twig-filters-and-functions)

Input can be either a DateTime compatible object, a Drupal structured data item, a string or a timestamp.

Most filters have an option for month\_format, either `numeric`, `full` or `abbreviation` (default numeric)

### Filters

[](#filters)

- un\_date: Formatted as date `j.m.Y`
- un\_time: Formatted as time `g.i a.m.|p.m.`
- un\_datetime: Formatted as date and time `d.m.Y g.i a.m.|p.m.`
- un\_html\_datetime: Formatted as date and time `Y-m-dTH:i:s`
- un\_daterange: Formatted as date and time `j.m.Y g.i a.m.|p.m. — g.i a.m.|p.m.` or `j.m.Y g.i a.m.|p.m. — j.m.Y g.i a.m.|p.m.` if dates are different
- un\_daterange\_times: Formatted as date and time `g.i a.m.|p.m. — g.i a.m.|p.m.` or `j.m.Y g.i a.m.|p.m. — j.m.Y g.i a.m.|p.m.` if dates are different
- un\_timerange: Formatted as time `g.i a.m.|p.m. — g.i a.m.|p.m.`
- un\_year: Formatted as `Y`
- un\_month: Formatted as `m`
- un\_month\_full: Formatted as `F`
- un\_month\_abbr: Formatted as `M`
- un\_day: Formatted as `j`
- un\_hour: Formatted as `G`, `g`, `noon`, `midnight`
- un\_minute: Formatted as `m` or blank if zero
- un\_ampm: Formatted as `a.m.|p.m.` or blank

### Functions

[](#functions)

Most function accept a DateRange (compatible) object or 2 DateTime inputs.

- un\_is\_same\_date: identical
- un\_is\_same\_day: on the same day
- un\_is\_same\_month: in the same month and year
- un\_is\_same\_year: in the same year
- un\_is\_all\_day: all day event
- un\_is\_utc: using UTC timezone
- un\_is\_rtl: RTL locale
- un\_separator: the separator used
- un\_duration: Return duration as human readable string

Human readable RRUle
--------------------

[](#human-readable-rrule)

Currently using  but  looks nicer

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance41

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 88.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 ~65 days

Recently: every ~105 days

Total

22

Last Release

485d ago

Major Versions

1.0.2 → 2.0.02023-12-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/346443feed98de86efcea04bbc5094dc2a4146181bca1e8936beb6ac46eed455?d=identicon)[unocha](/maintainers/unocha)

---

Top Contributors

[![attiks](https://avatars.githubusercontent.com/u/105144?v=4)](https://github.com/attiks "attiks (142 commits)")[![lazysoundsystem](https://avatars.githubusercontent.com/u/67453?v=4)](https://github.com/lazysoundsystem "lazysoundsystem (14 commits)")[![cafuego](https://avatars.githubusercontent.com/u/148719?v=4)](https://github.com/cafuego "cafuego (2 commits)")[![left23](https://avatars.githubusercontent.com/u/1835923?v=4)](https://github.com/left23 "left23 (2 commits)")

### Embed Badge

![Health badge](/badges/unocha-un-date/health.svg)

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

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[october/rain

October Rain Library

1601.7M83](/packages/october-rain)[pressbooks/pressbooks-book

This theme is named after Canadian media theorist Marshall McLuhan, who coined the phrase “the medium is the message.” It is designed for academic writing and is also suitable for fiction. Headings are set in Cormorant Garamond, and body type is set in Lora.

216.7k](/packages/pressbooks-pressbooks-book)[mediawiki/maps

Adds various mapping features to MediaWiki

84152.3k3](/packages/mediawiki-maps)[silverstripe-themes/simple

The SilverStripe simple theme (default SilverStripe 3 theme)

411.3M8](/packages/silverstripe-themes-simple)

PHPackages © 2026

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