ich Jquery Datetime wie diese bin mit:Jquery Datetime-Bild zeigt nicht die richtigen Daten
<script type="text/javascript">
$(document).ready(function() {
$("#LessonDateTime").datetimepicker(
);
});
</script>
und wenn in der Textbox, wenn kein Wert ist, wird standardmäßig zum heutigen Datum und wenn ein Wert ist, der Datetime-Picker geht bis 1899 wie in der folgenden Abbildung dargestellt:
I ein Ansichtsmodell verwenden die zu binden, ist unten:
public class AppointmentViewModel
{
public long? UserId { get; set; }
public long Id { get; set; }
public string AppointmentInstructorName { get; set; }
[DisplayFormat(ApplyFormatInEditMode =true, DataFormatString ="{0:dd/MMM/yyyy h:mm tt}")]
public DateTime? LessonDateTime { get; set; }
public string AppointmentLessonAddress { get; set; }
}
view:
@{ViewBag.PageTitle = "Edit an Appointment";}
<script type="text/javascript">
$(document).ready(function() {
$("#LessonDateTime").datetimepicker(
);
});
</script>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.Hidden("userId", Model.UserId)
<div class="row">
<div class="col-md-8">
<div class="panel">
<div class="panel-heading tabbable" tabindex="0"><h1>Edit Appointment Details</h1></div>
<div class="panel-body">
<div class="form-group row">
<div class="col-sm-6">
@Html.LabelFor(model => model.AppointmentInstructorName, "Instructor Name", htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.AppointmentInstructorName, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
@Html.LabelFor(model => model.LessonDateTime, "Lesson Date and Time", htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.LessonDateTime, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
@Html.LabelFor(model => model.AppointmentLessonAddress, "Address (if different)", htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.AppointmentLessonAddress, new { htmlAttributes = new { @class = "form-control" } })
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
<input type="submit" class="btn btn-primary form-control" value="Submit" />
</div>
</div>
</div>
</div>
</div>
</div>
}
scheint, wie Ihr String-Format für Datetimes ist entweder nicht korrekt? –
Also was * genau * ist deine Frage? Möchten Sie, dass es auf das aktuelle Datum zurückgesetzt wird, wenn kein Wert vorhanden ist, oder möchten Sie verhindern, dass es bei Wert auf 1899 geht? –
@BviLLe_Kid: Ich will, dass es aufhört, 1899 zu gehen und sollte heute oder das Datum in das Textfeld gehen, wenn möglich – Baahubali