datetimepicker
datetimepicker copied to clipboard
Time changing between AM/PM when clicking into the field
Everything works as expected, however I have an issue that is perplexing me... When I click into the date field and then click out without changing/clicking the time, It changes the PM into AM. When the time is noon, it will add 12 hours and change to the next day in the field.
JQuery version: 1.12.4
DateTimePicker Version (from the JS file):
- @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015
- @version 1.3.3
HTML:
Script: $('#Start').datetimepicker({ formatTime: 'h:i A', formatDate: 'd.m.Y', format: 'm/d/Y h:i A', step: 30 });
Also experiencing this issue.
I'm encountering the same issue. Here's the code I'm using:
if(!$("##meetingPicker").prop("readonly")) {
$('##meetingPicker').datetimepicker({
formatTime:'g:i A',
format: 'm/d/Y h:i A',
step: 15,
minDate: new Date(),
startDate: new Date(),
onSelectTime: function(current_time, $input) {
parseStartDate($input.val());
}
});
}
function parseStartDate(dateTimeStr) {
var regex = /(\d{1,2})\/(\d{1,2})\/(\d{4})\s+(\d{2}):(\d{2})\s+(AM|PM)/g; /*RegEx to parse Date-Time selected*/
var match = regex.exec(dateTimeStr);
if(match != null && match.length == 7) {
$("##hdnDay").val(match[2]);
$("##hdnMonth").val(match[1]);
$("##hdnYear").val(match[3]);
$("##hdnTime").val(match[4] + match[5]);
$("##hdnAMPM").val(match[6]);
}
}
I haven't dug into the source too deeply, but I'm guessing it has to do with formatter. In my experimentation if I removed "A" from the end of the format string so it wasn't displaying the AM/PM, it also wouldn't advance the day by 1 like it was when it was jumping forward 12 hours. It also only appears when I select a 12:XX value for the time. If I select 1:00, it has no problems.
I'm experiencing the same issue. Any solutions?
My solution was to use another datetime script.
+1
This post is almost a year old, but here is how I solved it. Upgraded to the 2.5 version of jquery.datetimepicker.full.min.js and added "validateOnBlur: false"
.datetimepicker(
{ minDate: 0,
format:'m/d/Y h:i a',
formatTime:'h:i a',
defaultTime:'8:00',
validateOnBlur: false,
step:30
});
I have the same problem. I noticed it happens only when AM/PM mode is used and Hour 12 is selected (AM or PM) kevinneibarger 's solution worked for me. Thank you Kevin. Version upgrade is not necessary. validateOnBlur: false,
sukrub, that doesn't solve the other 2 issues quoted here: https://github.com/xdan/datetimepicker/issues/657#issuecomment-383386369
My solution was to use another datetime script.
I know this is five years later.. however I'd be curious and much appreciate if you'd share which datetime script you used in lieu of datetimepicker. Many thanks!