Keyword

Setting the default time on 00:00:00 instead of 12:00:00

  • Uzi
  • Uzi's Avatar Topic Author
  • Offline
  • Premium Member
More
5 years 11 months ago #167477 by Uzi
So I had this issue before, but I resolved it using the following script:
// 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
  • Uzi's Avatar Topic Author
  • Offline
  • Premium Member
More
5 years 11 months ago - 5 years 11 months ago #167485 by Uzi
Ok I found the solution:

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: 5 years 11 months ago by Uzi.

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
5 years 11 months ago #167495 by Krikor Boghossian
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 :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum