Date formatting in Smarty
If you use the so called, German date format (day of month. month. year) you may have wondered how to achieve it with Smarty - without the leading zeroes for month.
You all know the common way to format date in Smarty:
-
{$myDate|date_format:"%e. %m. %Y"}
If you ever wanted to have month number without the leading zeroes, here’s how:
-
{$myDate|date_format:"%e. %#m. %Y"}
or even a cooler way:
-
{"j. n. Y"|date:$myDateTimestamp}
(because you can use almost any PHP function as Smarty variable modifier, just solve the parameters-order problem)
Question
Got any better solution? Tell me about it!