Set start day of the week in jQuery UI Datepicker?
JqueryJquery UiJquery Problem Overview
I'm looking through the docs for the jQuery UI Datepicker (http://jqueryui.com/demos/datepicker/), but I can't find how to set the first day of the week as Monday.
Applying regional settings will set Monday as first day of the week, but this will also change the language.
Jquery Solutions
Solution 1 - Jquery
Here is an example config I use. Look at the last line with "firstDay: 1". I think using sytax like this to specify datepicker options looks better ;)
$('#datepickerfield').datepicker({
constrainInput: true, // prevent letters in the input field
minDate: new Date(), // prevent selection of date older than today
showOn: 'button', // Show a button next to the text-field
autoSize: true, // automatically resize the input field
altFormat: 'yy-mm-dd', // Date Format used
beforeShowDay: $.datepicker.noWeekends, // Disable selection of weekends
firstDay: 1 // Start with Monday
})
Solution 2 - Jquery
Try the firstDay option (in the options tab):
//getter
var firstDay = $('.selector').datepicker('option', 'firstDay');
//setter
$('.selector').datepicker('option', 'firstDay', 1);
Solution 3 - Jquery
for using first day as monday :
$(function() {
$( "#date_id" ).datepicker({ firstDay: 1 });
});
Solution 4 - Jquery
You can also achieve this by creating your own localization file for your language along with your own settings. See this page for details: http://docs.jquery.com/UI/Datepicker/Localization
Solution 5 - Jquery
function getFirstDateOfThisWeek(d)
{
var TempDate = new Date(d || new Date());
TempDate.setDate(TempDate.getDate() + (@Config.WeekStartOn - 1 - TempDate.getDay() - 7) % 7);
return TempDate;
}
var StartDate = getFirstDateOfThisWeek(new Date()); //1st date of this week