Date filter

Build Status Downloads this Month Latest stable

Require PHP 5.4+.

This extension is for php Nette framework.

Installation to project

The best way to install h4kuna/date-filter is using composer:

$ composer require h4kuna/date-filter

How to use

Register extension for Nette in neon config file.

    dateFilterExtension: h4kuna\DateFilter\DI\DateFilterExtension

Now show you how set new date filters and other variants.

You can overwrite default latte filter date!

For define format use letters from table date function.

You can set own filters groups like:

		cze: # name of group is optional (i choose country)
			# filter name: format
			day: D
			date: j. n. Y # overwrite default latte filter
			dateTime: j. n. Y H:i:s
			day: D
			date: d/m/Y
			dateTime: d/m/Y H:i:s

First group is default. Now in latte you can use:


You can forget on this and duplicate on every place where you need.

{$date|date:'j. n. Y H:i:s'}

For different country you can change date format. And change it by:

/* @var $dateTimeFormat h4kuna\DateFilter\DateTimeFormat */
$dateTimeFormat = $container->getService('dateFilterExtension.dateTimeFormat');
$dateTimeFormat->format('dateTime', 'now'); // internaly call filter from latte

If you don't change locale, then date letters (D, l (lower L), F, M) are everytime in english language, ok here is example how change it.

		cs: # name of group is optional (i choose language) it isn't same group above
			# days:
			l: # lower L long
				# original name: translate
				Monday: Pondělí
				Tuesday: Úterý
				Wednesday: Středa
				Thursday: Čtvrtek
				Friday: Pátek
				Saturday: Sobota
				Sunday: Neděle

			D: # short
				Mon: Po
				Tue: Út
				Wed: St
				Thu: Čt
				Fri: Pá
				Sat: So
				Sun: Ne

			# months:
			F: # long
				January: Leden
				February: Únor
				March: Březen
				April: Duben
				May: Květen
				June: Červen
				July: Červenec
				August: Srpen
				September: Září
				October: Říjen
				November: Listopad
				December: Prosinec

			M: # short
				Jan: Led
				Feb: Úno
				Mar: Bře
				Apr: Dub
				May: Kvě
				Jun: Čvn
				Jul: Čvc
				Aug: Srp
				Sep: Zář
				Oct: Říj
				Nov: Lis
				Dec: Pro
		en: [] # we don't need translate

First group is default. Change group like:

/* @var $dateTimeFormat h4kuna\DateFilter\DateTimeFormat */
$dateTimeFormat = $container->getService('dateFilterExtension.dateTimeFormat');
$dateTimeFormat->format('day', 'now()');

No release at this moment. Try to create first one.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette