From your model you should have the DateTime property.
public class YourModel {
public DateTime YourDateField { get; set; }
}
Then in yourView
you could do:
@Html.LabelFor(m => m.YourDateField);
Accessing it using JavaScript/jQuery
:
$(document).ready(function() {
var d = $("#YourDateField").val();
alert(d);
$("#YourDateField").val = "01/01/2000"; // sets the date which will then be posted back to the model on the form submit.
});
This will alert the date value from your model.
$("#YourDateField").val = "01/01/2000";
Changes the date client side. If yor View has a Form
element, when it is submitted back to the server the value passed back will reflect the change (01/01/2000).
Date
object?