#Is it possible to change the display locale of dates?

6 messages · Page 1 of 1 (latest)

warm pewter
#

I found the afterRead hook but it can just change the value of the date but i want the date to keep its value but be displayed in another format.

I want something like this on the field.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString?retiredLocale=de

The toLocaleDateString() method returns a string with a language-sensitive representation of the date portion of the specified date in the user agent's timezone. In implementations with Intl.DateTimeFormat API support, this method simply calls Intl.DateTimeFormat.

hidden walrus
#

Sorry if you tried this already but might be dateFormat in the payload config

golden radish
warm pewter
warm pewter
#

This sounds like the thing i should use but somehow it does not affect the display format in the admin panel.

elder thicket
#

I use this dateFormat: "do MMMM yyyy, h:mm a". But it only works for collection lists. Even though the docs state. dateFormat: Global date format that will be used for all dates in the Admin panel. Any valid date-fnsformat pattern can be used. https://payloadcms.com/docs/admin/overview#admin-options I gave up for multi language support 🙂

Payload CMS

Manage your data and customize the Admin Panel by swapping in your own React components. Create, modify or remove views, fields, styles and much more.