genxgeek
genxgeek

Reputation: 13357

How to set "default" date (day highlight) on datetimepicker?

Per Trent Richardson's datetimepicker...How can I set the 'default' date on the calendar?

The following works for setting today as if it were selected/clicked:

$( ".selector" ).datepicker( "setDate", "11/12/2012" );

...but I can't figure out how to set default day (light blue with red circle when the calendar is displayed - what I really want is the date to be set to 12th)?

enter image description here

Upvotes: 1

Views: 3104

Answers (2)

genxgeek
genxgeek

Reputation: 13357

Managed to hack this together based on default and schema colors.

.ui-datepicker .ui-state-highlight {
   border: 1px solid #d3d3d3; 
   background: #e6e6e6;
   color: #363636;}
.ui-datepicker .ui-state-active {
   border: 1px solid #aaaaaa; 
   background: #518bdf url(images/ui-bg_glass_65_518bdf_1x400.png) 50% 50% repeat-x; 
   font-weight: normal; 
   color: #fff; 
   outline: none;}

$.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]),
$dp = inst.dpDiv;
this._base_gotoToday(id);
var tp_inst = this._get(inst, 'timepicker');
now = new Date();
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this._setTime(inst, now_utc);
$('.datetime:focus').datepicker('setDate', now_utc);
// $('.ui-datepicker-today', $dp).click();

};

Upvotes: 0

Bruno
Bruno

Reputation: 5822

You can set a default date by setting the value of the input field.

​$("#picker").datepicker().val( "12/11/2012" );​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

Unfortunately I think what you are referring to is today's date which is highlighted in blue. I doubt this is customisable.

Upvotes: 1

Related Questions