I'm trying to use DateTimePicker in my application. I create Date.cshtml under the View/Shared/EditorTemplates folder and it consist something like this:
@model System.DateTime
@Html.TextBox("", Model.ToString("dd-MM-yyyy"),
new {@class = "tanggal", @maxlength = "10"})
then I create EditorHookup.js file under the script folder with the content like this:
$(document).ready(function () {
$('.tanggal').datepicker({
dateFormat: 'dd-MM-yyyy'
});
});
I expect to get the result to be like this: 01-01-2012 but the result is: 01-January-20122012
What should I do to fix that?
Use mm
for month instead of MM
. See here: http://docs.jquery.com/UI/Datepicker/formatDate
E.g.:
dateFormat: 'dd-mm-yy' //notice the year format also has been changed, per Izkata's comment