genxgeek
genxgeek

Reputation: 13357

How to set date (for current day as highlighted) on calendar for jquery datetimepicker?

I'm using the Trent Richardson's datetimepicker here. How can I set the date on the calendar? The following sets the time correctly but the date as highlighted as current day is not getting set. In this particular example I'm hijacking the "now" button click to set the current UTC date/time.

$.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]),
$dp = inst.dpDiv;
this._base_gotoToday(id);
var tp_inst = this._get(inst, 'timepicker');
var now = new Date();
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
//
// Time gets set correctly but the date highlight for current day is not getting set in the calendar picker.
this._setTime(inst, now_utc);
$('.ui-datepicker-today', $dp).click();

Upvotes: 0

Views: 1287

Answers (1)

cssyphus
cssyphus

Reputation: 40078

Since Trent Richardson's datetimepicker relies on the jQueryUI, I presume its methods and settings are related. So,

Perhaps something like:

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

OR

$.datepicker.setDefaults({
    defaultDate: 1,

This might not be what you're looking for, just brainstorming.

References: jUI defaultDate setDate

Upvotes: 1

Related Questions