R Syed
R Syed

Reputation: 1093

Jquery Datepicker Default time 00:00:00 GMT

Right now when I use jquery date picker the default time is 00:00:00 GMT(7pm EST prev day) for any day I choose. Is there a way I can change the default time, so that when I choose any particular day the defaul time will be 12:00:00 GMT(7am EST same day).

Thanks

Upvotes: 1

Views: 2099

Answers (1)

adeneo
adeneo

Reputation: 318242

I'll give it a try, and this seems to work for me, as I'm guessing the problem is only evident when getting the date and trying to use it for something, as the jQuery datepicker does'nt show the time :

//prototype a new function on the date object to add hours
Date.prototype.addHours= function(h){
    this.setHours(this.getHours()+h);
    return this;
}
//start a datepicker
$("#dateP​​").datepicker();

//get the date and add 12 hours
var date = $("#dateP").datepicker('getDate').addHours(12);
​

FIDDLE

Upvotes: 1

Related Questions