- Posts: 140
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- Setting the default time on 00:00:00 instead of 12:00:00
Setting the default time on 00:00:00 instead of 12:00:00
- Uzi
- Topic Author
- Offline
- Premium Member
Less
More
6 years 7 months ago #167477
by Uzi
Setting the default time on 00:00:00 instead of 12:00:00 was created by Uzi
So I had this issue before, but I resolved it using the following script:
Unfortunately this has stopped working. Idk why, but maybe it has to do with the new flatpickr.
I cannot seem to fix this javascript so I'm checking if I can edit the core .js of the k2 flatpicker instantiotion to add this little snippet:
Which changes the default from PM to AM which results in going from 12:00:00 to 00:00:00. I cannot seem to find it. Can someone help me out?
// A $( document ).ready() block.
jQuery( document ).ready(function($) {
console.log( "ready!" );
});
if (document.getElementById("publish_down")){
document.addEventListener('DOMContentLoaded',function() {
document.querySelector('input#publish_down').onchange=changeEventHandler;
},false);
}
function changeEventHandler(event) {
// You can use “this” to refer to the selected element.
var pubdown = jQuery("#publish_down").val();
var newString = pubdown.substr(0, pubdown.length-8);
newString += " 00:00:00"
jQuery("#publish_down").val(newString);
}
Unfortunately this has stopped working. Idk why, but maybe it has to do with the new flatpickr.
I cannot seem to fix this javascript so I'm checking if I can edit the core .js of the k2 flatpicker instantiotion to add this little snippet:
onReady: function() {
if (this.amPM)
this.amPM.textContent = "AM";
}
Which changes the default from PM to AM which results in going from 12:00:00 to 00:00:00. I cannot seem to find it. Can someone help me out?
Please Log in or Create an account to join the conversation.
- Uzi
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 140
6 years 7 months ago - 6 years 7 months ago #167485
by Uzi
Replied by Uzi on topic Setting the default time on 00:00:00 instead of 12:00:00
Ok I found the solution:
in the /media/k2/assets/k2.js OR /media/k2/assets/k2.backend.js
Find this line:
Now add the above snippet to this:
in the /media/k2/assets/k2.js OR /media/k2/assets/k2.backend.js
Find this line:
if($('input[data-k2-datetimepicker]').length){
$('input[data-k2-datetimepicker]').each(function(){
var options = $(this).data('k2Datetimepicker');
if(options){
$(this).flatpickr(options);
} else {
$(this).flatpickr({
enableTime: true,
enableSeconds: true,
allowInput: true,
});
}
});
}
Now add the above snippet to this:
if($('input[data-k2-datetimepicker]').length){
$('input[data-k2-datetimepicker]').each(function(){
var options = $(this).data('k2Datetimepicker');
if(options){
$(this).flatpickr(options);
} else {
$(this).flatpickr({
enableTime: true,
enableSeconds: true,
allowInput: true,
onReady: function() {
if (this.amPM)
this.amPM.textContent = "AM";
}
});
}
});
}
Last edit: 6 years 7 months ago by Uzi.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
6 years 7 months ago #167495
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Setting the default time on 00:00:00 instead of 12:00:00
Hello Uzi,
Make sure to keep a backup of this file, so you won't lose your changes :)
Make sure to keep a backup of this file, so you won't lose your changes :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- Setting the default time on 00:00:00 instead of 12:00:00