Problem that needs to be solved:
- Getting time and date from a MVC application
My specific problem: I have a parking management application. As it is possible to book a parking spot up-front I need to know parking start time and date. For my model I used DateTime because MSDN advertises it as full featured time and date data type:
The .NET Framework DateTime class provides a full-featured interface for writing programs that deal with time.
My research: I have searched answers or typical solutions(best practises) for this kind of problem and almost all I got was:
- problems with globalization
- problems with timezones
- different date formats
But nothing considering how to get date and time conveniently with MVC application.
Closest answer I found was Scott Hanselman's 2009 solution - http://www.hanselman.com/blog/SplittingDateTimeUnitTestingASPNETMVCCustomModelBinders.aspx
Other solutions that people tend to use are different jQuery plugins.
To me these solutions seem to be sligthly over-engineered. As I dont know where else to ask and if these are the only solutions or not - my question is:
- What are my options getting time and date with MVC - best practice?
In my model I use:
[DataType(DataType.DateTime), DisplayFormat(DataFormatString = "{0:HH:mm dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? ParkingStartTime { get; set; }
In my view I use:
<div class="editor-label">
@Html.LabelFor(vm => vm.newCarOnParkingSpot.ParkingStartTime)
</div>
<div class="editor-field">
@Html.EditorFor(vm => vm.newCarOnParkingSpot.ParkingStartTime)
@Html.ValidationMessageFor(vm => vm.newCarOnParkingSpot.ParkingStartTime)
</div>
This solution give me a HTML5 datepicker, but no time inserting option : https://i.stack.imgur.com/fGPTV.png
It is my first question, so please be gentle if I have mistaken with this question.