dat/datetime field, how can I strip the time off?
dat/datetime field, how can I strip the time off?
I am using ASPNET Core and my DateTime
's are being serialized back like so: "2018-12-25T15:19:25.5594555"
I tried to use the field type of "date"
but HTML5 does not know how to parse that and there is not an option to specify the input format yet.
I tried to use "datetime" (without jQuery UI) but the format does not seem to control the output of the initial set until a date is picked via the picker.
One solution is to use the AddJsonOptions
IMvcCoreBuilder
member to set MvcJsonOptions
via something like this:
options.SerializerSettings.DateFormatString = "yyyy-MM-dd";
but I do not want to go messing with Core defaults and cause issues for other clients.
Ideally, DataTables would initialize the datetime
field type with the format I specified. Also, I am aware this exists: https://datatables.net/plug-ins/sorting/datetime-moment but hopefully I am missing something simple and I dont have to pull this in and go updating all of my field definitions.
Answers
Currently have something like this.
This will zero out the time on submit if there existed one before, which I think is fine. It would be nice to have some display only representation. Until edited.
Hi,
Assuming you are using the .NET Core libraries for Editor, use a get / set formatter - e.g.:
Allan
Sorry Alan, I am using this library and not the provided Core Libraries because I want to use Entity Framework Core. https://github.com/AlexanderKrutov/DataTables.Queryable