moment.js and Editor datetime
moment.js and Editor datetime
Hello folks, I tried adding moment.js to my page to help format some dates. Once I did this, the look and behavior of the Editor fields of type datetime seemed to change. I'm using the .NET Editor server-side, and the model class has these properties as type DateTime? (nullable DateTime). They appear in the JSON as a string like "2018-11-02T00:00:00". Before using moment.js, in the Editor, they would be formatted as 2018-11-02, and the date picker would match the date. Now, they appear like 2018-11-02T00:00:00, and the date picker centers on today's date. Hope that makes sense. I may be a version or two behind on the Editor and DataTables (using editor 1.7.3, DataTables 1.10.15). Thanks.
Before moment.js:
After moment.js:
Answers
Ah, if I set the Editor DateTime opts momentStrict to false, it works. It also seems like, if I use a string type instead of DateTime for the property and use Format.DateSqlToFormat(Format.DATE_ISO_8601) on the server side, it should also work. Thanks.
Thanks for posting back. Yes, the get and set formatters are the way to approach this. Generally the approach DataTables and Editor take is that the client-side should see and work in a single format only. The server should then do any conversion that is needed.
Allan