express-admin
express-admin copied to clipboard
Time is not shown correctlly for mysql db
For the following column type as I got from settings.json the display is not correct and produces errors when saving.
{ "name": "created_at", "verbose": "created_at", "control": { "text": true }, "type": "datetime", "allowNull": true, "defaultValue": null, "listview": { "show": true }, "editview": { "show": true } }
When I load the row the field is showing the following information:
Sun Jan 21 2018 19:53:30 GMT+0100 (Central European Time)
If I try to save I get an error saying:
Error: Check out the highlighted fields below.
and the field below shows me in red:
malformed
When I look at the table using mysql command line tool I see:
2018-01-21 19:53:30
If I paste what I took from mysql into the field than the row is saved but I get the error I mentioned above with a success message. Here are the 2 messages. success is green and the other is red.
Success: The record have been saved. Error: Check out the highlighted fields below.
I had the same issue with timestamp fields. I think the settings.json is just incorrectly generated with the wrong control type for datetime/timestamp fields. Changing "control": { "text": true }
to "control": { "datetime": true }
gives you the correct output format and gets rid of the errors. It also makes a datetime picker appear when you edit the input.