setFormatter for mariaDB/mysql timestamp?
setFormatter for mariaDB/mysql timestamp?
Digo
Posts: 8Questions: 3Answers: 0
Hello!
I tried to select/update a mysql-timestamp in the editor:
Field::inst( 'mydate' )
->getFormatter( Format::dateSqlToFormat('d.m.Y H:i') )
->setFormatter( Format::dateFormatToSql('Y-m-d H:i:0' ) ),
but this seems not be the correct way to do this (record ends up with current date, not the date entered)
Any suggestions what I have to use as setFormatter?
Thanks
Digo
Answers
You seem to be retrieving the date in a different format than what you send to the server. That looks a bit odd. Are you really transforming the date format on the client side?
This is what "dateFormatToSql" does:
The sql date format in PHP is this: ('Y-m-d H:i:s')
You seem to be "imitating" that format in your setFormatter. But you need to specify the format that is arriving on the server, not the target database format.
Hi Digo,
In addition to rf1234's comment, one other useful bit of information for us would be to see how you have the field configured on the client-side please.
Allan
Hello!
Thanks for your replies!
Here is what I want to do:
ok - now I know, that dateFormatToSql defines the format, I send it to the server.
So I changed it to:
Now the date is being saved - but time is converted to 00:00
Config of field at client:
{ data: "StartDatum", className: 'editable' },
Any suggestions?
Thanks
Digo
Just use a custom setFormatter.Then you can append the date coming from the client and render it yourself for database update.
There is more in this thread and in the docs of course:
https://datatables.net/forums/discussion/comment/151630/#Comment_151630
Thanks!
I added some client configuration
and now it is working fine. ok. the date-picker is broken, but this seems to be a css problem :-)
Digo
Wow yes - I've never seen it quite so broken. There must be conflicting CSS somewhere.
If you find something that you think we should add an override for in the date picker's CSS, let me know.
Allan