I am using jquery UI datepicker on MVC2 to set my startdate picker.
When I go to the ‘create’ view, I want the datepicker to hold its minimal value- which is today.
But for some reason I see the date format string like this: mm/dd/yyyy HH:MM:SS AM or PM.
only before the user pick a date- after the user picks a date I get the format that I want: mm/dd/yyyy in both of my datepickers- dateStart and dateEnd
and when I go to edit, I get the value from the database (date datatype) and have the same problem.
this is my code:
$(function () {
var buttonImage = $(".selector").datepicker("option", "buttonImage"); // date image
// Datepicker
$('#DateStart').datepicker({
inline: true,
showOn: 'both',
buttonImage: '/Content/calandar2.gif',
minDate: '+0',
dateFormat: 'mm/dd/yy',
onSelect: function (dateStr) {
var min = $(this).datepicker('getDate') || new Date(); // Selected date or today if none
$('#DateEnd').datepicker('option', { minDate: min });
}
});
$('#DateEnd').datepicker({
inline: true,
showOn: 'both',
buttonImage: '/Content/calandar2.gif',
dateFormat: 'mm/dd/yy',
minDate: '+0'
});
}
THANK YOU!!!
It sounds like your issue is with the HtmlHelper and the DateTime value.
or
Which by default will call
DateTime.ToString()If that is the case you can either convert it to be simply
If you are using templates you can also do this: