firecmsco / firecms

Awesome Firebase/Firestore-based CMS. The missing admin panel for your Firebase project!
https://firecms.co
Other
1.14k stars 184 forks source link

Cant get Date type field to work #618

Closed gerontius closed 3 months ago

gerontius commented 7 months ago

I'm submitting a date time field to a collection and its ending up fine in the collection in date/time format but its not rendering it in the CMS i get incorrect date format error message. I can get it to work by passing it as a string, but not as a date. I tried to get a on_create field working as per the API documentation but i just get an empty read only field. Here is my code in React:

// const submitDate = new Date().toLocaleDateString("en-GB"); //const submitDate = new Date().toLocaleString("en-GB"); const submitDate = new Date().toISOString();

Ive tried all three but same effect.

type Issue = { submitDate: Date; ... }

     submitDate: buildProperty({
        dataType: "date",
        name: "Created at",

// doesnt matter what mode i add here }),

It looks like the CMS is expecting MM-DD-YYYY HH:MM and only that. If thats the case it has to be in that format then I will have to stick with the string as UK users will get confused by that.

fgatti675 commented 7 months ago

Where exactly are you using this code? const submitDate = new Date().toISOString(); Note that there is a locale prop in the main app config that allows you to set the date locale format. I think that should help you

fgatti675 commented 3 months ago

Closing for lack of activity