Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Is there a way to change the format for dates in the admin UI?

default discord avatar
jakehopking2 years ago
3

I don't want to use the US or UK standard for dates (

mm/dd/yyyy

and

dd/mm/yyyy

respectively), and would like them to display as

yyyy/mm/dd

Can we set this as a global preference?



This date is horrible for me to read... the day/month is ambiguous and I've made a whole array of errors here thinking that this was UK formatted dates and not US. As said I'd prefer ISO date here to remove any ambiguity.



admin: {
  displayFormat: 'YYYY/MM/DD',
},


Produces console errors.



I've checked your docs, and I can't see a guide on how these can be formatted. I only see the default formatting.



and

pickerAppearance

is throwing type and console errors??



-



  • default discord avatar
    jessrynkar2 years ago

    Hey

    @357456032454410240

    , you need to nest

    displayFormat

    in a

    date

    object:



    admin: {
        date: {
            displayFormat: 'yyyy/MM/dd',
        }
    }


    There is an example here but it could definitely be clearer in the docs:

    https://payloadcms.com/docs/fields/date#example

    Also you will get errors for YYYY and DD because they are not valid tokens so change that to

    yyyy/MM/dd

    , read more about that here

    https://github.com/date-fns/date-fns/blob/main/docs/unicodeTokens.md
  • default discord avatar
    jakehopking2 years ago

    Thanks for this info

    @854377910689202256

    - is it possible to set this at a global level?

  • default discord avatar
    jessrynkar2 years ago
    @357456032454410240

    currently it is not possibly to set this at a global level but I can definitely see the benefit in that - we should open a feature request for this 👍

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.