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:
-
"%e. %m. %Y"}
If you ever wanted to have month number without the leading zeroes, here’s how:
-
"%e. %#m. %Y"}
or even a cooler way:
-
"myDateTimestamp"
-
{"j. n. Y"|date:$myDateTimestamp}
(because you can use almost any PHP function as Smarty variable modifier, just solve the parameters-order problem)
Edit 2011/10/25: Just found out that date_format:”%e. %#m. %Y” no longer works in one of my projects, I guess they moved them to a different server. Fortunately, there’s yet another solution: use a hyphen instead of a hash mark.
-
"%e. %-m. %Y"}