
Since I’ve not found a timepicker suitable for my needs (although there are some pretty decent ones out there) I decided to make one. I needed date-time and just time, so built it on top of jQuery UI’s Datepicker, so I have access to just one or both. A couple key features in this addon I’ve not found in a few of the others is time formatting, seconds, time step (10 min, 20 min, 30 min, etc..). Not to mention that all datepicker options should still be available.
If you use just datepicker you have no changes in your code. If you decide to use date and time, then there is a function for you:
$('.datetimeinput').datetimepicker();
And if you just want a timepicker:
$('.datetimeinput').timepicker();

This still uses datepicker just for time, but it hides the calendar and strips out the formatting for the date, thus only leaving the time. I’ve put together some documentation and examples as there are quite a few additional options besides just datepicker options.
Timepicker Addon Documentation
Related posts:


138 Responses
Jeffrey Gilbert
19|Apr|2010nice.
kcp
20|Apr|2010One of the cleanest timepicker solutions ive seen! Great Work!
Abai
21|Apr|2010Hello, Trent!
Thanks for a awesome datetimepicker plugin!
ARuizNa
21|Apr|2010It`s an excelent addon.
But…
I´m having problems with the stepMinutes, if a set it with 30 the UI slide do not detected the first change, which one should show “30″ in the minutes field. This do not stop there, if I return to “0″ position in the minutes field insert “30″.
Can you help me.
Thanks
,Regards.
Chris
23|Apr|2010Awesome control!
Really simple and efficient, though I just have a quick question.
Is there any way to just get out the time parts of the control? For example I have two time pickers (one for a start time, one for an end time) and I want to use the hour and minute parts to calculate a “total trip time.”
Thanks again.
trent
23|Apr|2010ARuizNa,
I noticed this one time but I think it was just the UI Sliders acting funny.. not sure if it has to do with the new UI 1.8 or not.. its not declared the stable version yet, its just compatible with jQuery 1.4. The plugin may work with the UI 1.7 and jQuery 1.3 though..
Chris,
I may need to add some getters and setters, or add the time to the callback methods so they can be accessed there. If you are handy with javascript the current time for that picker is always kept in hour, minute, and second variables of the Timepicker class.. just need to add those parameters to the callback function (on the source side, then you can grab them on your side). This is version 0.1 so there are still a couple small things like this to be added..
ARuizNa
28|Apr|2010Thanks trent for the quick answer… I understand this is de version 0.1 an it working excellent for this number. :)
,Regards.
Charles
29|Apr|2010Hello,
I’m moving over from the datepicker, and to set the date, my call:
$(‘.date-pick’).datepicker(“setDate”, new Date(“March 12, 2010″) );
causes an error, so I tried:
$(‘.date-pick’).datetimepicker(“setDate”, new Date(“March 12, 2010″) );
but that does not set the date.
How do I set the date?
Thanks
Reinout
30|Apr|2010Looks great!
I had to make a small change though since any hour below 12 changed to it’s PM alternative when working with a 24 hour schedule :
this.ampm = ((treg[order.t] == undefined) ? ” : (treg[order.t].charAt(0).toUpperCase() == ‘A’) ? ‘AM’ : ‘PM’).toUpperCase();
to :
this.ampm = ((treg[order.t] == undefined || treg[order.t].length == 0) ? ” : (treg[order.t].charAt(0).toUpperCase() == ‘A’) ? ‘AM’ : ‘PM’).toUpperCase();
since treg[order.t] is an empty string and not undefined, and as a result in the former case I always ended up with “PM” instead of an empty string.
trent
30|Apr|2010Charles, this is part of some of the current short coming of version 0.1. You can maybe set the date in your .date-pick text
$(‘.date-pick’).text(‘March 12, 2010′);
$(‘.date-pick’).datetimepicker();
Then the date should be set. I am currently looking at how to extend datepicker better so that you still have access to these functions..
Reinout,
Thanks for the catch, I will update the source with this correction. I’ve got a few notes on improvements, the next release should be significant as far as functionality is concerned
Jeremy
30|Apr|2010Fantastic work, this is by far the best date and time picker I’ve seen. I like how you retained the original date picker, and implemented your work as an add on.
I made one change to the addTimePickerFunction. I changed line 62, from “.replace(/\s/g,’\\s?’);” to “.replace(/\s/g,’\\s?’) + ‘$’;” because my time format is “hhmm” instead of “hh:mm” so the regex wasn’t able to isolate the time components of the text.
Jeremy
30|Apr|2010I also overrode the _doKeyPress event of the date picker like you did with the _selectDate. I needed the ability to allow spaces because a user needs to enter the time portion by typing.
Not my favourite solution, but it works.
$.datepicker._doKeyPress = function(event) {
var inst = $.datepicker._getInst(event.target);
if ($.datepicker._get(inst, ‘constrainInput’)) {
var chars = $.datepicker._possibleChars($.datepicker._get(inst, ‘dateFormat’));
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
return event.ctrlKey || (chr -1);
}
}
rangzen
01|May|2010Hello,
how do you specify a date format with mm used by month and date?
Thanks.
trent
03|May|2010most all date operations should follow the original datepicker options
trent
03|May|2010Thank you Jeremy for posting your fix, much appreciated!
Reinout
03|May|2010Jeremy, I created another fix for updating the time in the textbox, but I had to request an update on the jquery library for this :
http://dev.jqueryui.com/ticket/5574
What I added in the datepicker code :
_notifyUpdate: function (inst) {
var onNotifyUpdate = this._get(inst, ‘onNotifyUpdate’);
if (onNotifyUpdate)
onNotifyUpdate.apply();
},
And inside the _updateDatepicker event I added :
this._notifyUpdate(inst);
},
In the _timepicker addon code :
injectTimePicker: function (inst) {
var $theDP = $(‘#’ + $.datepicker._mainDivId);
// Prevent displaying twice
if ($theDP.find(“div#ui-timepicker-div”).length == 0)
…
And (below onClose) :
onClose: function (dateText, inst) {
tp.updateDateTime(inst, tp);
if ($.isFunction(o['onClose'])) o.onClose(dateText, inst);
},
onNotifyUpdate: function (inst) {
tp.addTimePicker();
if ($.isFunction(o['onNotifyUpdate'])) o.onNotifyUpdate(inst);
}
The textbox is not updated yet when changing the sliders, but I will try that later on. I want to get this fixed properly first.
Reinout
04|May|2010Forget my last comment, I did it in another way. Will try to send the updated script by e-mail since it will be cumbersome to post every change in comment.
trent
04|May|2010I posted a few of the changes last night to make version 0.2.
Avi
04|May|2010Very cool, very smooth, integrates nicely. It has two problem that I see:
1) when you select a date, the datetimepicker remains open, as it should, and it updates the input field, as it should… but it wipes out the time. The time is updated only when you close.
2) minDate: If you use minDate option for the datepicker, it really sets the hour to an odd hour.
Avi
04|May|2010I haven’t figured out the minDate, but I did get the live update by a slight mod of your code.
1) Replace line 277-278 (inside $.datepicker.selectDate) as follows
/* BEGIN DELETE
if (inst.input)
inst.input.val(dateStr);
END DELETE */
/* BEGIN ADDED */
// our dateStr must include the time
var doUpdate = this._get(inst,”updateDateTime”);
if (doUpdate) {doUpdate(inst);}
else {
if (inst.input)
inst.input.val(dateStr);
}
/* END ADDED */
2) Inside jQuery.fn.datetimepicker (around line 247), after onClose:, add the following
updateDateTime: function(inst) {
tp.updateDateTime(inst, tp);
}
It now updates the date and time every time you select a date. For the time as well, in real-time update, the following works:
3) At the end of onTimeChange: (around line 157-158), add the following:
this.updateDateTime(inst.inst,inst);
Voila.
Jeremy
04|May|2010Avi, I think your change causes the date/time to be set as soon as you open up the date picker. I don’t think that is necessarily desired behavioir
ronald
06|May|2010NICE LOOKING ADD-ON!!!!
I want to use this great addon but i have a little problem.
I want to display the timepicker when i click a inputfield. The first time i click in the inputfield it does nothing (firebug places an extra div with noting in it). Only when i click the inputfield for a second time (after clicked somewhere else) the timepicker pops up.
The datepicker DOES work but i only need to set the time..
Does anyone have an idea why?
Thanks!
chris
24|May|2010Yeah – this is the closest I’ve found to a perfect date/time plugin – great work, Trent.
Pardon my greediness but I could REALLY use these two things though:
1.) A fix for for wonkiness with the minutes slider (I’m trying to set in 30 minute steps but like others it’s behaving oddly onload, and as I drag it)
2.) Ability to control range of hours allowed (i.e. force 6AM – 9PM selection only)
Is there anyone out there who has already hacked in either of these things themselves?
Darek
25|May|2010I have problem with datetimepicker:
If:
and:
$(“something”).datetimepicker();
… and this input is in . When I don’t select date, and save form, next time when I show this form whith this data (this saved record), plugin write in input CURRENT DATE. I check the database – date in this rerord is empty.
Darek
25|May|2010I have problem with datetimepicker:
If:
”
and:
$(“something”).datetimepicker();
… and this input is in ”. When I don’t select date, and save form, next time when I show this form whith this data (this saved record), plugin write in input CURRENT DATE. I check the database – date in this rerord is empty.
Ricci
26|May|2010I’m really thankful for this add-on to the datepicker. :) I also would like to solicit some insights on incorporating this to the date range. at the moment im only using the sample code for date ranges, and somehow would like to add the time value in the logic.
$jq(document).ready(function() {
var dates = $jq(‘#daterangetag-1, #daterangetag-2′).datepicker({
showButtonPanel: true,
defaultDate: “+1w”,
numberOfMonths: 2,
onSelect: function(selectedDate) {
var option = this.id == “daterangetag-1″ ? “minDate” : “maxDate”;
var instance = $jq(this).data(“datepicker”);
var date = $jq.datepicker.parseDate(instance.settings.dateFormat || $jq.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker(“option”, option, date);
}
});
Thanks very much if you could shed some light on this. :)
Dan
28|May|2010I’ve got the min hours max hours working:
changed file to support an hourMax and hourMin value, which can now be called in the original constructor. Added these fields into timepicker default, with default values. In inject timepicker -> tp_inst.hour_slider = $tp.find(‘#ui_tpicker_hour’) -> have added min, set to tp_inst.defaults.hourMin and have changed max from 23 to tp_inst.defaults.hourMax. Now declare in constructor hourMin:10 etc.
However, having issues getting the timepicker to display in a Grid edit template field. Have been tyring to use jQuery live -> $(“.timepicker”).live(‘click’, function () {
$(this).datepicker({showOn:’focus’}).focus();
This will display if I click it, then click something else, then click the field again. It won’t display first click. By comparison, the datepicker will display first click with the above line of code.
Kevin Pauli
08|Jun|2010Nice work. I have a data binding framework I wrote, and I found it necessary to add this at line 265 so that it would fire the change event I am listening for:
this.$input.trigger(‘change’);
Peter
14|Jun|2010@Chris / and anyone else who has issues with the Minute slider,
I had an issue with the Minutes slider. I set the step values to 5 min increments and after sliding and going back to the beginning the slider would default to 5 and not 0. It appeared the instance of the slider was reading the previous value after calling the update. I corrected this by updating the minute slider instance code (around line 154). I passed in the event and the ui instance into the slide function (which contain the correct current value of the slider, ui.value) and updated the global minute slider instance with the ui.value. I also setup a local variable for max minute time, which calculates what the max minutes should be based on the step min, instead of hard coding 59, which was causing errors as well. For example if you set a step min of 5, you shouldn’t see 59 at the end, it should stop at 55, which it wasn’t doing.
Here is the code below…
CALCULATION TO FIGURE OUR MAX MIN (added this to the top of the injectTimePicker function)
var minMax = 59 – (59 % tp_inst.defaults.stepMinute);
BEFORE…
tp_inst.minute_slider = $tp.find(‘#ui_tpicker_minute’).slider({ orientation: “horizontal”, value: tp_inst.minute, max: 59, step: tp_inst.defaults.stepMinute, slide: function() { tp_inst.onTimeChange(dp_inst, tp_inst);} });
AFTER…
tp_inst.minute_slider = $tp.find(‘#ui_tpicker_minute’).slider({ orientation: “horizontal”, value: tp_inst.minute, min:0, max: minMax, step: tp_inst.defaults.stepMinute, slide: function(event, ui) {
tp_inst.minute_slider.slider( “option”, “value”, ui.value );
tp_inst.onTimeChange(dp_inst, tp_inst);
} });
I made this comment earlier on a different blog post on this site and Trent was going to place this fix as soon as he could get to it. Hopes this helps!
Mitch
18|Jun|2010Hello,
Maybe i am doing something wrong but it appears that the timepicker does not trigger the onchange event.
can anybody tell me how to make it trigger?
Nilesh
26|Jun|2010What I added in the datepicker code :
_notifyUpdate: function (inst) {
var onNotifyUpdate = this._get(inst, ‘onNotifyUpdate’);
if (onNotifyUpdate)
onNotifyUpdate.apply();
},
And inside the _updateDatepicker event I added :
this._notifyUpdate(inst);
},
In the _timepicker addon code :
injectTimePicker: function (inst) {
var $theDP = $(‘#’ + $.datepicker._mainDivId);
// Prevent displaying twice
if ($theDP.find(“div#ui-timepicker-div”).length == 0)
…
And (below onClose) :
onClose: function (dateText, inst) {
tp.updateDateTime(inst, tp);
if ($.isFunction(o['onClose'])) o.onClose(dateText, inst);
},
onNotifyUpdate: function (inst) {
tp.addTimePicker();
if ($.isFunction(o['onNotifyUpdate'])) o.onNotifyUpdate(inst);
}
The textbox is not updated yet when changing the sliders, but I will try that later on. I want to get this fixed properly first.
Matt
24|Jul|2010This is by far the best datetime picker I have seen! Exactly what I was looking for, nice work!
BUT… I am stuck, for now, with jQuery 1.3 and jQuery UI 1.7. Do you expect this to be compatible?
I’ve tried it in this environment, and am finding that the next/prev in the datepicker section is not changing the month, so you cannot move beyond the existing month for date selection.
Do you think that this is an issue w/ the older jQuery? I see the examples use 1.4. Do you have any suggestions??? Figured it was worth asking…
Thanks!
Jarek
24|Aug|2010Thanks for this plugin. It’s great.
Eduardo
01|Sep|2010It’s amazing but i am missing a feature.
In the standard datepicker i always use the altField: and altFormat: so it seems the h:m:s is not getting propagated to the altFormat.
Also the mm format in the datepicker is for month leading zero so there is a conflict with minutes here.
Any chance to add this feature?
Thanks
Radical
16|Sep|2010Once I click the empty text box the date time is set at lost focus and then it is impossible to make the text box empty again. Or it is also impossible to make empty the text box after a date is selected. My date is not mandatory and user should be able to set blank date or remove the date. How it is possible?
Dominic
21|Sep|2010I can’t get it to work with datepicker ‘Event Search’ where you have two datapicker fields with an id of #from and #to.
The datetimepicker calendar opens and closes fine, and I can choose a time but when I choose a date it takes me to a different page on my site.
I’ve tried over-riding with an additional onclick event and added .preventDefault() but then the calendar won’t open at all.
Dominic
21|Sep|2010Further to this problem. I noticed that there is an error thrown up in FireBug which says that the dates variable is undefined. If I comment out the line
// dates.not( this ).datepicker( “option”, option, date );
it stops the page going to a new page on my site but I also lose the ‘Event Search’ capability – so this is not a solution.
Gerrit
22|Sep|2010Is there a way to use the timepicker fixed on a page – not as popup?
I tried this for a div container:
$( “#datepicker” ).datetimepicker();
But there are no time-controls.
Fman
23|Sep|2010CAN’T CLEAR IT!
Hi,
if I click in an emtpy textfield, the DateTime-Picker opens, field stays empty.
When I close the picker without selecting any date/time, the field ist autofilled!
When I click in the textfield to clear it, the DateTime-Picker opens again…endless loop.
How can one remove a datetimevalue in the textfield? Is there a Clearbutton e.g. available?
regards,
FM
trent
23|Sep|2010Fman, Are you using the version from the docs or github? I recently committed a fix for this on github:
http://github.com/trentrichardson/jQuery-Timepicker-Addon
trent
23|Sep|2010Gerrit, this issue has been fixed in the latest commit on Github
Fman
23|Sep|2010Hi trent,
upgraded to your Githhub version (rather than version on this site), works perfect now
thx,
FM
Leanne
07|Oct|2010Hi there, I can’t seem to get the date/time picker working. I’m not sure why. It displays NaN instead of numbers and the time picker doesn’t display at all? (http://citysouthphysio.website.2010.360southclients.com/book-appointment.html) If someone could help me, that’d be great :)
Leanne
07|Oct|2010Ok, I worked it out, seeing that I’ve got the system inside Joomla, MooTools was the problem. Great script by the way! :)
Grant
21|Oct|2010Is there any way to not have the field that the picker uses be read only? I have some people who like to use the picker, but some like to type it manually.
trent
21|Oct|2010Grant, it shouldn’t be readonly, there may be a bug in the latest release. Check the version on Github
Grant
21|Oct|2010I just downloaded the code from Github.
http://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/jquery-ui-timepicker-addon.js
I’ll check to see if there’s a bug elsewhere on my page.
Thanks
Grant
22|Oct|2010It looks like it has to do with the jQuery populate alternate field option, not your customization. When using that the field the calendar uses is read only.
http://jqueryui.com/demos/datepicker/#alt-field
Thanks
Alejandro Diep
22|Oct|2010i had the same problem as Dan’s comment (#27) and a (maybe) hard workarround was add the ‘mouseover’ eventType and it works for me.
$(“#hour”).live(‘mouseover click’, function() {
$(this).timepicker({showSecond: true, timeFormat: ‘hh:mm:ss’, stepSecond: 10});
});
manfer
27|Oct|2010This works really well.
The only problem I found is that I have no way to parse the datetime to get a Date. The jquery datepicker gives that posibility with getDate method. If I call that function in a datetimepicker I get a Date with only the date not a Date with date and time because it calls the jquery datepicker method. It would be fantastic if this add-on had its own getDate method taking hour into account too.
Or maybe there is a way and I haven’t figured out how.
trent
27|Oct|2010Hey manfer,
In the version on Github there is an attempt to get this working. However it needs some fine tuning to get it working smoothly if you are at all handy with some js/jquery. I’ve not had a ton of time to spend with it the last couple weeks.
I’m even ok if it comes down to creating a separate method getDateTime/setDateTime rather than overriding datepicker’s methods
Nelvios
27|Oct|2010Hey trent,
Thanks for the addon, it’s a really nice one :). Still, I’m kinda getting a problem here. See, I have multiple datetimepickers in one of my forms. When I change any of the datetimepickers, the input value changing is only the first one. Can you fix it? Please?
sas
28|Oct|2010What is minimum requirements Which versions of jQ and jQ UI? I cannot make this work.
Kyle
05|Nov|2010Has anyone been able to use the timepicker as an inline option? I tried, but the only way I know of being able to use datepicker inline is utilizing the callback feature:
onSelect : function(dateStr, inst) {
$().val(dateStr);
}
I tried to modify the timepicker with very little success. Too new I guess. Any guess/help?
Adam Edwards
11|Nov|2010The problem stated by Dan in post #27 can be solved easily by changing the click event which is bound to live to focus as below:
// Bind datepicker to start input
$(‘#input’).live(‘focus’, function() {
$(this).datetimepicker();
});
dotTwelve
18|Nov|2010Hi,
$.datetimepicker.(“getDate”) is returning me for examle this cases:
19.11.2010 0:00:00 -> Fri Nov 19 2010 00:00:00 GMT+0100 (Central Europe Standard Time)
19.11.2010 6:40:23 -> Fri Nov 19 2010 00:40:23 GMT+0100 (Central Europe Standard Time)
19.11.2010 11:40:23 -> Fri Nov 19 2010 00:40:23 GMT+0100 (Central Europe Standard Time)
19.11.2010 12:00:00 -> Fri Nov 19 2010 00:00:00 GMT+0100 (Central Europe Standard Time)
19.11.2010 23:59:59 -> Sat Nov 20 2010 01:59:59 GMT+0100 (Central Europe Standard Time)
trent
18|Nov|2010looks like the hours aren’t setting properly?
snicky
18|Nov|2010Sorry for a stupid question, but… how to change the text on the ‘Done’ button?
snicky
18|Nov|2010OK, I just needed to use ‘closeText:’
monlio
25|Nov|2010Hello sorry for my bad english.
Thanks for datetimepicker addon, it’s working very well, but I’ve got a problem, i would like to use two dates (one start_date one end_date) end_date depending of the start date. I try a script wich is working with datepicker but i need to select hours and minutes. But when i use datetimepicker, the second date is not depending of the first. Can you help me please.
Thanks for all.
monlio
My script:
$(function () {
$(‘#date_depart’).datetimepicker({
//beforeShow: customRange, appel de la fonction AVANT
duration: ”,
showTime: true,
time24h: true,
constrainInput: true,
formatDate: ‘dd-mm-yy’,
stepMinute: 5,
timeText: ‘horaire’,
hourText: ‘heures’,
minuteText: ‘minutes’,
hourGrid: 4,
minuteGrid: 10,
minDate: +1, maxDate: ‘+1Y +1M’ //mindate = ajourd’hui ET maxDate = dans un an + 1 mois
});
var checkInDate = $(‘#date_depart’);
var checkOutDate = $(‘#date_retour’);
checkInDate.datetimepicker({ onClose: clearEndDate });
checkOutDate.datetimepicker({ beforeShow: setMinDateForEndDate });
function setMinDateForEndDate() {
var d = checkInDate.datetimepicker(‘getDate’);
if (d) return { minDate: d }
}
function clearEndDate(dateText, inst) {
checkOutDate.val(”);
}
});
dapio
28|Nov|2010great work! i have problem with option defaultDate, which was in original datepicker. Is there option to set up date at the beginning?
alex
16|Dec|2010very very bad…. it’s not possible to initialize date from beginning… or set date through jscript directly….
this sample does not work at all!!!
ex13.datetimepicker(‘setDate’, (new Date()) );
but i think it must work
i use :
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 0.7
* Last Modified: 10/7/2010
in extjs it may like – dp.setValue(new Date) – simple and smart
but this timepicker is VERY awful
trent
16|Dec|2010alex,
Please upgrade, there have been many signifigant revisions since version 0.7, including setDate method. Go to the Github page and pull from dev. Hopefully then you will retract your “AWFUL” statement :)
dGo
21|Dec|2010very nice indeed…
The nicest script I’ve found so far.
thanks !
Victoria
19|Jan|2011Hi
Is there a way to disable Now button ?
thanks
Victoria
Will
27|Jan|2011I think there’s a bug in the latest version (0.9.2 and 0.9.3) – the displayed time and time sliders are not correctly reset when the picker is opened and no time is specified in the target textbox.
To repro:
1. Open the datetimepicker from an empty textbox – both the date and time selections are correctly initialized to their default values
2. Close the picker and specify a date/time in the textbox and open the picker – both the date and time selections are correctly set to the values specified in the textbox
3. Close the picker again, clear out the date/time in the textbox, and open the picker – now the picker displays the correct date, but the displayed time and time sliders are not reset to their original default values (i.e. 12:00 AM)
-Will
Hermit
28|Jan|2011I have traced the slider problem to the line
treg = timeString.match(new RegExp(regstr, ‘i’)); in the datepicker addon code.
its showing the value as 01/28/2011 12:10 pm,2,10,pm In hours it is showing 2 instead it should show 12. I think the regstr is not being constructed properly
trent
28|Jan|2011Hermit,
Please pull the latest from the dev branch on github, it includes this fix among others
Hermit
28|Jan|2011I have been using Version 0.9.2 which i downloaded from the page
https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/master/jquery-ui-timepicker-addon.js
Isnt this the latest code?
trent
28|Jan|2011Close but not quite. That link pulls from master. The Dev branch has the fix:
https://github.com/trentrichardson/jQuery-Timepicker-Addon/blob/dev/jquery-ui-timepicker-addon.js
cdbrkpnt
31|Jan|2011the hour issue fixed
and is working great with simple addition of this code at line no 184
.replace(/h{1,2}/ig, ‘(\\d{1}?\\d)’)
avk
01|Feb|2011Fix for Hour Issue:
change line 198 to
regstr = ‘.{‘ + dp_dateFormat.length + ‘,}[\\s*' + this._defaults.separator.replace(/\s/g, '\\s?]‘) + regstr;
Lupin Sansei
03|Feb|2011As far as I can see there are still two bugs in the github repository:
One is the timepicker doesn’t render am/pm initially when it opens, only after an update of the sliders. This can easily be fixed by removing the if statement on line 540 that checks if something was updated.
The second is more subtle, when you set a minimum time to be selected that has a minute value, then this minimum will be enforced for all hours of the “critical” day, not just the minimal hour.
Keep up the great work!
Lupin Sansei
03|Feb|2011sorry the line number in the github version is 550, it was 540 is my local patched version
trent
03|Feb|2011Hey Lupin,
I believe if you pull from the dev branch the am/pm bug is fixed. The second I believe you want the look at the differences between the options minuteMin and minDateTime as one of those may better suit your need?
Khalid
07|Feb|2011Hi,
I am using this great addon and i want to be able to disable it and enable it on demand, is it possible?
Thanks by advance.
Lupin Sansei
07|Feb|2011Hey Trent,
thanks for your reply, the am/pm bug is fixed, nice! I don’t understand the advantage of minuteMin or minDateTime though. minDate does exactly what I want it, it allows the user to only select a timestamp (i.e., date and time) larger than minDate. However, on the minimal day, and only on it, the minutes cannot be lowered below the minutes specifed in minDate, even if the hour is larger than the minimal hour allowed. Do you understand what I mean? Maybe I’m missing something obvious!
Thanks!
Lupin
Jadsadah
17|Feb|2011Hi Trent – really great work!
I’m trying to get some functionality, but unfortunately without results. Is it possible to set (or rather dunamically change) the minDate option, after init like in the case of pure datapicker?
$( “.selector” ).datepicker( “option”, “minDate”, new Date(2007, 1 , 1) );
I’m able to dynamically limit the range of dates using (where #fromTime is datetimepicker in fact), but only dates (not the time (hour/minutes constraint)):
$(“#fromTime”).datepicker(‘option’, ‘minDate’, new Date(dtMin));
$(“#fromTime”).datepicker(‘option’, ‘maxDate’, new Date(dtMax));
Regards,
Jadsadah
17|Feb|2011I found a some kind of workaround, but i’m not especially happy from this resolution:
$(“#from”).datetimepicker(‘destroy’); //destroying previous object
//and once again, creation of datetimepicker in the same div ID
$(‘#from’).datetimepicker({
ampm: false,
showSecond: false,
stepMinute: 15
, minDate: new Date(dtMin),//new dtMin
maxDate: new Date(dtMax)//new dtMax
});
Any better ideas? :)
My best regards guys!
ingemar
04|Mar|2011hi,
thanks for the great timepicker addon :)
i have following problem:
$(‘#datetime_from’).bind(‘dateSelected’, this._onLoginButtonClicked);
how can i bind to the dateSelected event?
thanks,
ingemar
arthur moura
13|Mar|2011can not invoke the functions for fields cloned.
function () {
$(‘#horarios’).append(“”);
var novoCampo = $(‘.selectData:first’).clone();
var nrDeCamposData = $(‘.selectData’).length;
novoCampo.attr(‘name’, ‘horarios[' + nrDeCamposData + '].hora’);
$(‘#horarios’).append(novoCampo);
$(‘.selectData’).timepicker(); // don`t work.
}
actually happen?
Naveed
17|Mar|2011hi,
i want to update input box with selected date when click on done button, not on just selecting date or time. it update when done is clicked
Rohit
25|Mar|2011Hello ,its very helpfull.i am new in jquery. Can anyone tell me how can i change theam of that datepicker.
Jonny
29|Mar|2011Message: Object doesn’t support this property or method
Line: 344
Char: 4
Code: 0
I’m getting this error. Any ideas?
trent
29|Mar|2011Do you have jquery ui included with datepicker and slider modules?
kenny
01|Apr|2011i haveset default time
hour: 15, minute: 30,second: 0,
and it displays that time when i open datepicker however if i click done without changing anything it will not pick up date and time, i need to change something (date.hour,mnute) then change it back before it picks up date and time
Parag
04|Apr|2011nice work trent. thanks a lot…
DoanAnh
12|Apr|2011Hi Trent, your addon is so great but i dunno why i cannot get it working in my project. It seems that i downloaded all the necessary files (jquery js & css: jquery-1.4.4.min.js, jquery-ui-1.8.6.custom.min.js, jquery-ui-timepicker-addon.js and jquery-ui-1.8.6.custom.css). do i miss st?
DoanAnh
12|Apr|2011Oh, sorry i got it working. My mistake!
Phil
14|Apr|2011Hi Guys! Is there’s a way or options to configure or change the slide div into select option box? Need help with this. Thanks in advance.
trent
15|Apr|2011Currently there is no option for this. It would require a bit of restructuring as the plugin is currently built around the sliders, but would be possible, and probably not super complex change…
nishad
25|Apr|2011Can’t seem to make this work.
this is my HTML code
|
$(‘#example1′).datetimepicker();
Felipe Salazar
20|May|2011getDate doesn’t work for the timerpicker, whether I use $(‘#example3′).timepicker(‘getDate’) or $(‘#example3′).datetimepicker(‘getDate’) or … try it on example3
Cy
26|May|2011Hey, I have the same feature request as Eduardo (#34). Any chance of this getting implemented?
priya34074
21|Jun|2011Hi
I have From datetime as say 21st Jun’11 17:25 and I want To datetime not to be lesser than From datetime if , I am using the code below:
onClose: function () {
$(“input[Id$='txtDueDate']“).val(”);
var min = new Date(Date.parse($(“input[Id$='txtDueFrom']“).val()));
$(“input[controltype$='DueTodate']“).datetimepicker(“option”, “minDate”, min);
}
});
It sets the MinDate to 21st jun but it allows to select time less than 17:25 .
Please suggest correction in my code.
Sapana
21|Jun|2011this time picker is not working with jquery-1.5.1.min.js and jquery UI 1.8.13
Rishad
22|Jun|2011Hello. Thanks for this great widget.
1 problem:
When I load my form, that includes the widget, and I already have a date and time for eg. 23-May-2011 09:00. Then I click on the calendar button which loads the datetimepicker and the calendar is set to the correct date, but the time slider is set to 00:00. Ideally, the time slider should have been at 09:00.
Is there a setting that I’m missing?
Thanks, Rishad
GoneNuts
08|Jul|2011Hi thank you for the this great looking addon but I cant get the dam thing to work :( I can get the date picker to work but not the addon can some one help me please before I go nuts.
jQuery UI Datepicker – Default functionality
$(function() {
$( “#datepicker” ).datepicker();
});
$(function() {
$( “#timepicker” ).timepicker();
});
Date:
Date:
GoneNuts
08|Jul|2011Hi I tried to post my code but it will not post complete
trent
08|Jul|2011Do you have the slider widget included in your jqueryui?
GoneNuts
08|Jul|2011Thank You trent worked a teat didn’t mention about those scripts to be included in the docs thanks again
chandan
11|Jul|2011I have used this plugin. Thanks
How to validate the start date Time and end date time. Please help me.
Gaboo
26|Jul|2011Dear Trent,
I have an issue regarding the Timepicker under IE9 and Safari browsers.
The problem is that only the two buttons “Now” and “Done” appears in Timepicker area.
Note:
In IE7, IE8, FF, it appears as it should (included time display, hour and minute slider and picker)
My timepicker code looks like as follows:
$(‘#input_box’).timepicker({
ampm: false,
stepMinute: 5,
hourGrid: 4,
minuteGrid: 10,
onSelect: onSelectCallbackTo
});
Do you have any idea how to resolve this problem?
Any advice and solution are appreciated.
Thanks in advance.
Regards,
Gaboo
Christoph
03|Aug|2011First of all: it is a great work. But I have a problem to integrate it in a Typo3 webpage. I don’t think it is a datetimepicker issue but I don’t find any hints to solve the following issue:
datetimepicker opens and everything can be selected. But if using the sliders to set hour and minute the slider won’t stop anymore. Even if the datetimepicker is closed the value of hour and/or minute will still change when moving the mouse. Only refreshing the page will quit this behaviour.
Any ideas?
Thx, Christoph
ProSmash
13|Sep|2011Hi Trent, awesome work. I have the same question as Rishad (#97):
When I load my form, that includes the widget, and I already have a date and time for eg. 23-May-2011 09:00. Then I click on the calendar button which loads the datetimepicker and the calendar is set to the correct date, but the time slider is set to 00:00. Ideally, the time slider should have been at 09:00.
Is there a setting that I’m missing?
Is this posible to accomplish?
trent
18|Sep|2011ProSmash,
Check to make sure your dateFormat and timeFormat options are exactly correct to match your date time
Shafaqat
19|Sep|2011Hi
I am getting this error, please help
Object doesn’t support this property or method
I have included following files
“Scripts/jquery-1.6.1.js”
“http://trentrichardson.com/examples/timepicker/js/jquery-ui-timepicker-addon.js”
“jquery-ui-1.8.15.custom.min.js”
“jquery-ui-1.8.15.custom.css”
trent
19|Sep|2011Are you sure you source is correctly linked to the source files? Sounds like something is missing..
trent
21|Sep|2011Hey Shafaqat,
Be sure to include the jquery-ui before timepicker plugin
Troy
04|Oct|2011I’m trying to use the default time feature and it isn’t setting is on the datetimepicker.
Here is my code:
$( “#check_in_datepicker” ).datetimepicker( {
dateFormat: ‘yy-mm-dd’,
ampm: true,
timeFormat: ‘hh:mm tt’,
hour: 10,
minute: 0,
beforeShow: customRange,
onSelect: function(dateText, inst) {
— more code
}
});
Any thoughts?
chris
05|Oct|2011Love this and it works really well, however, I’m trying to set the maxDate property to a datetime on a dialog box that appears at during the course of entering some data – the maxDate needs to be reset to the current datetime each time the dialog appears but the only way I’ve managed to get this to work so far is by “destroying” the datetime element first and then resetting it’s maxDate option on re-initialisation.
Jadsadah mentioned this back in Feb and just wondered if you’d had a chance to look at this? The workaround “feels” wrong!
trent
07|Oct|2011Have you tried this with the latest version relesed this week? (0.9.7)
sshport
30|Oct|2011if i run this without params, like this: $(‘#example10′).timepicker();
it shows datatimepicker, to show timepicker i have to add at least one param $(‘#example10′).timepicker({hourGrid: 4});, why?
gaz
02|Nov|2011how to add this in the html and code in C# pleast post the full script
ankur rai
02|Nov|2011I am using a datetime range with a start and end date.
my problem is when i click my end datetime picker, after seleting startdatetime , in startdatetime textbox time is removing. please reply
my code is as fallows.
$(‘#example16_start’).datetimepicker({
onSelect: function (selectedDateTime){
var start = $(this).datetimepicker(‘getDate’);
$(‘#example16_end’).datetimepicker(‘option’, ‘minDate’, new Date(start.getTime()) );
}
});
$(‘#example16_end’).datetimepicker({
onSelect: function (selectedDateTime){
var end = $(this).datetimepicker(‘getDate’);
$(‘#example16_start’).datetimepicker(‘option’, ‘maxDate’, new Date(end.getTime()) );
}
});
dinu
15|Nov|2011Hi
It is an awesome plugin and works perfectly for me.But i need a help of you.Is there any parameter for checking the start time and end time for the time picker or it should be called by using some callback functions. If you got any code regarding start time and end time,please provide me with the solution.
Thanks in advance.
Steve
28|Nov|2011Bug in 0.9.7: using general styles for lists really screws things – I’m guessing the CSS needs to be better qualified/named. Try including this:
dl
{
border: 1px solid green;
padding: 0.5em;
width: 400px;
font-size: 16px;
}
dt
{
float: left;
clear: left;
width: 10px;
text-align: left;
font-weight: bold;
background: #339900;
color: white;
padding: 5px;
}
dt:after
{
content: “”;
}
dd
{
width: 370px;
margin: 0 0 0 20px;
padding: 5px 0 0.5em 10px;
}
Steve
28|Nov|2011BTW, fantastic addon!
elarifr
06|Dec|2011hello i have some issue using datetimepicker 0.98 from github + fr translation
the script
/* css for timepicker */
.ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
.ui-timepicker-div dl{ text-align: left; }
.ui-timepicker-div dl dt{ height: 25px; }
.ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
$(document).ready(function(){
$("#datimepicker").datetimepicker({
beforeShowDay: nonWorkingDates,
numberOfMonths: 2,
defaultDate: 1,
firstDay: 1,
minDate: +1,
maxDate: '+1M +15D',
showAnim: 'slide',
regional: 'fr',
dateFormat: 'yy-mm-dd hh:mm',
altField: '#alternate-datime',
altFormat: 'DD, d MM, yy hh:mm',
timeFormat: 'hh:mm',
separator: 'T',
//hourMin: '7',
//hourMax: '13',
//showSecond: false,
hourGrid: 2,
minuteGrid: 30,
stepHour: 1,
stepMinute: 30,
stepSecond: 10
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDates = [[7, 14, 2011], [11, 01, 2011]];
var closedDays = [[Monday]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
for (i = 0; i < closedDates.length; i++) {
if (date.getMonth() == closedDates[i][0] - 1 &&
date.getDate() == closedDates[i][1] &&
date.getFullYear() == closedDates[i][2]) {
return [false];
}
}
return [true];
}
});
Date de LivraisonSaisir la date comme AAAA-MM-JJ (exemple norme ISO 2011-10-24)
using only datepicker the field is ok and alternate field too
using datetimepicker
-time slide display 1 sec and hides and it does not appear until i select a day
-the alternate field only report the time hh:mm
-using dateFormat: ‘yy-mm-dd hh:mm’, report 2011-12-07 hh:12 => hh unknow and mm= month; time is ok alternate filed
-using dateFormat: ‘yy-mm-dd’, the field report date and time is reported on alternate
-removing dateFormat the input field report date 23/12/2011 and alternate the hours
- using hourmin & hourmax report an error
f is undefined
(function(a){a.widget(“ui.slider”,a.ex…,value:0,values:null}})})(jQuery);;/*
does datetimepicker handle the dateformat and alternate field ?
however it seems the mm is ambiguous
http://jqueryui.com/demos/datepicker/#date-formats report
ISO 8601 – yy-mm-dd use mm for month
elarifr
06|Dec|2011oops seems code create some effect :(
/* css for timepicker */
.ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; }
.ui-timepicker-div dl{ text-align: left; }
.ui-timepicker-div dl dt{ height: 25px; }
.ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
$(document).ready(function(){
$(“#datimepicker”).datetimepicker({
beforeShowDay: nonWorkingDates,
numberOfMonths: 2,
defaultDate: 1,
firstDay: 1,
minDate: +1,
maxDate: ‘+1M +15D’,
showAnim: ‘slide’,
regional: ‘fr’,
dateFormat: ‘yy-mm-dd hh:mm’,
altField: ‘#alternate-datime’,
altFormat: ‘DD, d MM, yy hh:mm’,
timeFormat: ‘hh:mm’,
separator: ‘T’,
//hourMin: ’7′,
//hourMax: ’13′,
//showSecond: false,
hourGrid: 2,
minuteGrid: 30,
stepHour: 1,
stepMinute: 30,
stepSecond: 10
});
function nonWorkingDates(date){
var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
var closedDates = [[7, 14, 2011], [11, 01, 2011]];
var closedDays = [[Monday]];
for (var i = 0; i < closedDays.length; i++) {
if (day == closedDays[i][0]) {
return [false];
}
}
for (i = 0; i < closedDates.length; i++) {
if (date.getMonth() == closedDates[i][0] – 1 &&
date.getDate() == closedDates[i][1] &&
date.getFullYear() == closedDates[i][2]) {
return [false];
}
}
return [true];
}
});
Date de LivraisonSaisir la date comme AAAA-MM-JJ (exemple norme ISO 2011-10-24)
elarifr
07|Dec|2011hi,
datetimepicker is really great addons. thanks for that
i have finally fixed some of my problems
- hourMin hourmMx was some ‘ added by template that i didn’t see :(
- alt date & time was ok by setting altFieldTimeOnly: false,
but still have
1/ time sliders shows one sec with provided value and disappear until i select a day
2/ alternate field use dateFormat timeFormat instead of altFormat
i have date: yy-mm-dd ; time hh:mm and i want alternate ‘DD, d MM, yy hh:mm’
is there a altDateTimeFormat ?
and now have a new mistake where time picker report date in input field and time in alt field :(
elarifr
trent
07|Dec|2011Hey elarifr, currently there is no altTimeFormat. This could potentially be a future addition but nothing at the moment.
For #1 do you have your time formatted differently while generating the page? .. In other words does php or python format the time with the Seconds, but the timeFormat doesn’t specify seconds? Thus when the picker changes value it doesn’t generate a Second on the time.
keith
08|Dec|2011This does look cool. Why do I not see anything other than a datepicker? Do I have all the write includes?
script type=”text/javascript” src=”scripts/jquery-1.7.1.js”>
script type=”text/javascript” src=”scripts/jquery-ui-1.8.16.custom.min.js”>
script type=”text/javascript” src=”scripts/jquery.ui.core.js”>
script type=”text/javascript” src=”scripts/jquery-ui-timepicker-addon.js”>
script type=”text/javascript” src=”scripts/jquery.ui.slider.js”>
elarifr
09|Dec|2011hi trent
i do not use second but i understand that it should be the issue.
thank for this answer.
for instance i have removed the datetime feature and use separate date & time that works very well as i must finish this work asap
after i will go back on using datetime and will check again what happens
elarifr
trent
09|Dec|2011Keith,
You should only need jquery, jquery-ui-1.8.16.custom.min.js, and timepicker-addon. Your jquery-ui-1.8.16.custom.min.js should already have included the datepicker and slider. Then, instead of calling $(‘#selector’).datepicker() you should use datetimepicker() or timepicker()
Justin
18|Dec|2011Hi Trent – thanks for the work on the plugin. I’m using the latest version and for some reason I am not able to see the time slider, only the calendar and the “Now” button (which does work).
I have included your CSS, and am importing the following javascript files:
This is the code that initializes the datetimepicker:
td.find(‘#dateinput’).each(function(){
jQuery(this).datetimepicker();
});
I have a screenshot of the output here – http://grab.by/bqj7 – any ideas?
Thanks!
Justin
Justin
18|Dec|2011Oops, lost my javascript imports in the comment:
script type=’text/javascript’ src=’http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js’
script type=’text/javascript’ src=’http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js’
script type=’text/javascript’ src=’/js/jquery-ui-timepicker-addon.js’
trent
18|Dec|2011Hey Justin,
Does that cdn provide the slider widget and CSS for the slider? Do you get any errors?
testa
13|Jan|2012$(‘#id’).timepicker({});
//Now how can i unbind/remove/hide the timepicker in routine?
Thanks!
Jo
19|Jan|2012Hi, I made a post here yesterday that was incorrectly identified as spam – can you please fish it out?!
fatih
21|Jan|2012Hi !
firstly thank you for this add on. it works great but i have some problem when i use this add on inline mode.
$.datetimepicker.(“getDate”) returns like this :
Sun Jan 29 12:00:00 UTC+0900 2012 in IE8.
Sun Jan 29 2012 12:00:00 GMT+0900 (Korea Standard Time) in Chrome and Firefox browser.
i think something is wrong in my code part. how can i get this format 29-01-2012 12:00:00 ?
my code is like this :
$(function() {
$( “#datepicker” ).datetimepicker({
dateFormat: ‘yy-mm-dd’,
timeFormat: ‘hh:mm:ss’,
inline: true,
showWeek: true,
showTime: true,
firstDay: 1,
numberOfMonths: 3,
//showButtonPanel: true,
hour: 12,
minute: 00,
stepMinute: 15,
hourGrid: 1,
minuteGrid: 15,
ampm: false,
onSelect: function(selectedDateTime){
var seldate=$(this).datetimepicker(‘getDate’);
document.getElementById(‘sdate’).value = seldate;
}
});
});
Thank you again for this great add on…
fatih
21|Jan|2012Hi again,
I found a solution.I just changed this line
document.getElementById(‘sdate’).value = selectedDateTime;
it works but i have a new problem about add time.I want to add time on current selectedDateTime.
example : 29-01-2012 12:00:00 + 1 hour 45 minutes. and i want to get this result 29-01-2012 13:45:00
is there any function for do this?
trent
22|Jan|2012faith,
On your first comment it appears you were trying to use the Date object as a string. The different browsers were converting the Date object to a string differently. Take a look at example 15 on the docs, the formatted DateTime string is passed to the onSelect option:
http://trentrichardson.com/examples/timepicker/
For the second question to add to a date have a look at this article:
http://trentrichardson.com/2011/09/27/better-javascript-date-add-and-diff/
fatih
23|Jan|2012thank you trent…
finally i found a solution.
fatih
23|Jan|2012Hi..
I have a new problem.I need to set mindate from now (example : 2012-01-23 19:47:00).but Minute bar doesn’t refresh when i use mindate option.
example : NOW 2012-01-23 19:47:00 and minute grid and steps are 5.hour bar shows 20-21-22-23 and minute bar show 52-57. but problem is when i changed hour bar value to next hours, minute bar grids and steps are still same.it shows 52-57.it should be 0-5-10-15-20-….55 for next hours (20-21-22-23).
How can i find a solution?
Thank you…
michele
02|Feb|2012Hello! Great Addon!
There is only a lack! the ALTFORMAT support!
Is very very important for me!
Is there a workaround for this? Maybe format the date before to insert in the altfield?
Sorry for my english!
trent
03|Feb|2012Some planning has been in the works for this option but it does not exist yet, sorry..
t.nition
05|Feb|2012Couldnt agree more, awesome addon, great work there. The only thing keeping me from using it is the altformat support!