I have a date in the database with this format "YY-mm-dd". On the template I want it in this format: dd.mm.YY Usually it would work with $date.Format('d.m.Y') But not in Silverstripe 4. It converts from 2018-05-08 to 8.0.2018. Only the year is correct. Was there a change. I didn't find anything in the Documentation
Date formats in SS4 were changed from PHP date formatting to CLDR date formatting (changelog link):
Changed Format() method to use CLDR format strings, rather than PHP format string. E.g. d/m/Y H:i:s (php format) should be replaced with to dd/MM/y HH:mm:ss (CLDR format).
You can use this to achieve what you want:
$Date.Format('dd.MM.y')
The guide mentioned in the previous answer regarding date formatting has moved. The new location for CLDR date formatting as used by Silverstripe 4 can be found here: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With