Topic: Timepicker always shows PM by default
Rafał Rogulski answered 8 years ago
swipiidev answered 8 years ago
swipiidev answered 8 years ago
swipiidev answered 8 years ago
Rafał Rogulski answered 8 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 commented 5 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 answered 8 years ago
sweta648 answered 5 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 5 years ago
Hi. How can I reproduce this issue? Can you create snippet here: https://mdbootstrap.com/snippets ?
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: General Bootstrap questions
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No