I have a view built on Bootstrap 3 and ASP.NET MVC 5 for editing user profile information, but it displays in the wrong format on the form.
The Neo4j database, and I use Neo4jClient to interact with the database from .NET. Neo4jClient requires using objects DateTimeOffsetinstead of objects DateTimeto use the Json.NET serializer to go to the Neo4j REST interface. Therefore, my model uses a DateTimeOffset object to save the birthday for the user.
Here is my form field in my opinion:
<div class="form-group">
<label class="col-md-4 control-label" for="Birthday">Birthday</label>
<div class="col-md-4">
@Html.TextBoxFor(model => model.Birthday, new { @class = "form-control input-md datepicker", placeholder = "Birthday" })
<span class="help-block">Please enter your birthday</span>
</div>
</div>
The date when printing on the form has the following format:
M/dd/yyyy hh:mm:ss t -zzz
However, it must have this format, since we only need a part of the date:
MM/dd/yyyy
DataFormatString , - :
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTimeOffset Birthday { get; set; }
DateTimeOffset? ?