Topic: Timepicker always shows PM by default
logiczone free asked 7 years ago
sweta648 free answered 4 years ago
Hello sir, I am facing same problem in clockpicker, when i am clicking in AM/PM clockpicker is hide and by default it will take PM. Please give me solution for it. Here is my code. $('.clockpicker').clockpicker({ twelvehour: true });
Grzegorz Bujański staff commented 4 years ago
Hi. How can I reproduce this issue? Can you create snippet here: https://mdbootstrap.com/snippets ?
Rafał Rogulski free answered 7 years ago
var timeToSend = $("#timeToSend").pickatime({
twelvehour: true,
default: 'now',
afterDone: function() {
var picker = timeToSend.data().clockpicker;
if(picker.options.twelvehour) {
var hours = picker.hours;
var minutes = picker.minutes;
var amOrPm = "AM";
if(minutes < 10) {
minutes = "0"+minutes;
}
if( new Date(Date(00)).getHours() >= 12) {
amOrPm = "PM";
} else {
amOrPm = "AM";
}
$("#timeToSend").val(hours + ":" + minutes + amOrPm);
}
},
afterShow: function() {
var picker = timeToSend.data().clockpicker;
if(picker.options.default == 'now') {
if( new Date(Date(00)).getHours() >= 12) {
$('.pm-button').trigger( "click" );
} else {
$('.am-button').trigger( "click" );
}
}
}
});
afterDone
methods fix time pass to input, afterShow
methods trigger a click event on PM or AM buttons and automatically change it in time picker.
Regards
sweta648 free commented 4 years ago
Hello sir, I am facing same problem in clockpicker, when i am clicking in AM/PM clockpicker is hide and by default it will take PM. Please give me solution for it. Here is my code. $('.clockpicker').clockpicker({ twelvehour: true });
swipiidev free answered 7 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No