I am trying to capture both date and time in MDriven, but the default for data type DateTime only shows a picker (in Web) for the date, but a time is stored in the persistency layer. How do I also capture the time?
Asked
Active
Viewed 63 times
2
-
I imagine your MDriven-generated app has a "web UI", and that MDriven will emit some kind of Javascript "calendar control", using either MVC.Net and/or AngularJS "widgets". Here's how to set Date-only vs. Date/Time with an MVC.Net calendar control: https://www.c-sharpcorner.com/article/displaying-calender-control-in-Asp-Net-mvc-without-jquery-an/ or https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions/using-the-html5-and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc/using-the-html5-and-jquery-ui-datepicker-popup-calendar-with-aspnet-mvc-part-4 – paulsm4 Mar 17 '18 at 21:48
-
Configure your Date/Time picker for "datetime" (vs. "date-only") ... and you'll also get a meaningful "time". It's as easy as that :) – paulsm4 Mar 17 '18 at 21:49
1 Answers
2
I found this in the wiki.mdriven.net
Date-formatting You set date and time format in the Style attribute enclosed in { }.
For example, for dates and time, {short} will show date and time in compact format. The default date format is {shortDate}. Please refer to the Angular guide for formatting dates https://docs.angularjs.org/api/ng/filter/date
The date and time format are automatically localized depending on the browser.

Hans Karlsen
- 2,275
- 1
- 15
- 15
-
1That dosen't cut it for me, trying that approach only styles the class. When I look at the HTML I think I want a "datetime-local" as input type instead of "date". Is "content override" the only way to control the input type? Or am I missing something? – Henrik Leijonhufvud Mar 18 '18 at 19:38
-
1Consider to keep the time part separate from the date part in the UI. One widget for changing the date and another for the time. If your data needs 1 datetime-column to store this you can easily still have two derived-settable attributes in your model - one for date and one for time. – Hans Karlsen Mar 19 '18 at 10:02
-
2I found the [MDriven wiki article on derived settable](http://wiki.mdriven.net/index.php/Derived_settable_attributes) and the example there solved the whole issue. The Derived settable was a bit hard to grasp but once understood it is super elegant way to solve this. – Henrik Leijonhufvud Mar 19 '18 at 18:32