jQuery UI Datepicker is coded to always highlight the user's local date using the class ui-state-highlight
. There is no built-in option to change this.
One method, described similarly in other answers to related questions, is to override the CSS for that class to match ui-state-default
of your theme, for example:
.ui-state-highlight {
border: 1px solid #d3d3d3;
background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;
color: #555555;
}
However this isn't very helpful if you are using dynamic themes, or if your intent is to highlight a different day (e.g., to have "today" be based on your server's clock rather than the client's).
An alternative approach is to override the datepicker prototype that is responsible for highlighting the current day.
Assuming that you are using a minimized version of the UI javascript, the following snippets can address these concerns.
If your goal is to prevent highlighting the current day altogether:
// copy existing _generateHTML method
var _generateHTML = jQuery.datepicker.constructor.prototype._generateHTML;
// remove the string "ui-state-highlight"
_generateHtml.toString().replace(' ui-state-highlight', '');
// and replace the prototype method
eval('jQuery.datepicker.constructor.prototype._generateHTML = ' + _generateHTML);
This changes the relevant code (unminimized for readability) from:
[...](printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + [...]
to
[...](printDate.getTime() == today.getTime() ? '' : '') + [...]
If your goal is to change datepicker's definition of "today":
var useMyDateNotYours = '07/28/2014';
// copy existing _generateHTML method
var _generateHTML = jQuery.datepicker.constructor.prototype._generateHTML;
// set "today" to your own Date()-compatible date
_generateHTML.toString().replace('new Date,', 'new Date(useMyDateNotYours),');
// and replace the prototype method
eval('jQuery.datepicker.constructor.prototype._generateHTML = ' + _generateHTML);
This changes the relevant code (unminimized for readability) from:
[...]var today = new Date();[...]
to
[...]var today = new Date(useMyDateNotYours);[...]
// Note that in the minimized version, the line above take the form `L=new Date,`
// (part of a list of variable declarations, and Date is instantiated without parenthesis)
Instead of useMyDateNotYours
you could of course also instead inject a string, function, or whatever suits your needs.