Search code examples
crafter-cms

Crafter CMS - Can the date format be set to a standard ISO format?


I'm using the REST api with Crafter CMS, and the dates are formatted in a US locale specific format like: m/d/y h:m:s

This is really surprising and I hope there is a good reason for it, but more importantly, can I change it globally so it uses a standard ISO format that is locale independent? Is it using the default Java locale, the system locale, or is it just hardwired that way? Right now I am parsing it and reformatting it, but I would rather not have to do that everywhere a date is used, and I'm afraid if it runs on another machine, the format might change to whatever the locale is there which would break everything.


Solution

  • Crafter CMS does not depend on the system locale to format dates, it will always use the same format in the UTC timezone. Currently the format is MM/dd/yyyy HH:mm:ss

    There is an open ticket to change it to ISO: https://github.com/craftercms/craftercms/issues/1415

    Meanwhile, you can update the Groovy REST scripts in the Headless Blueprint to do the conversion for you so you don't have to do it in your application.