Jump to content

[SOLVED] How to add hour:minute:second to the date filter in helperLists in prestashop?


Recommended Posts

For example, in cart rules controller there is a js file like this:
admin/themes/default/template/controllers/cart_rules/form.js

here you can find $('.datepicker').datetimepicker

this means that with jquery, you can make a datepicker with hour and minute and seconds

anywhere else that you see a datepicker you can change it to datetimepicker and then you have time picker

but for modern controllers there is another issue. I can not change it easy as it is with symfony and ... hate this change in PS

Link to comment
Share on other sites

Hi.
Add custom javascript loading to your module and controller.
You can then put in it when and where the datetimepicker will be loaded.

E.g:

Module:

public function hookActionAdminControllerSetMedia($params)
{
	if ($this->context->controller->controller_name == 'AdminModules' && Tools::getValue('configure') == $this->name){
		$this->context->controller->addJqueryUI('ui.datepicker');
		$this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/admin/js/admin.js');
	}
}

 

JavaScript:

$('.datepicker').datetimepicker();

 

 

Link to comment
Share on other sites

2 hours ago, prestashopfree.com said:

Hi.
Add custom javascript loading to your module and controller.
You can then put in it when and where the datetimepicker will be loaded.

E.g:

Module:

public function hookActionAdminControllerSetMedia($params)
{
	if ($this->context->controller->controller_name == 'AdminModules' && Tools::getValue('configure') == $this->name){
		$this->context->controller->addJqueryUI('ui.datepicker');
		$this->context->controller->addJS(_PS_MODULE_DIR_.$this->name.'/views/admin/js/admin.js');
	}
}

 

JavaScript:

$('.datepicker').datetimepicker();

 

 

thanks for the answer, yes that is the workaround for this scenario

but it needs a little more configuration

i will post it soon

Link to comment
Share on other sites

I added this to the view of modern controllers with this js file in a custom module:
 

// adds hour, minute and seconds to the time picker in any listing page you see in modern controllers

$(document).ready(function () {
    $('.datepicker input').each(function (i,e) {
        $(e).data("DateTimePicker").format('YYYY-MM-DD HH:mm:ss')
        $(e).data("DateTimePicker").sideBySide()
        if($(e).attr('value')){
            $(e).data("DateTimePicker").date($(e).attr('value'))
        }
    })
})

 

  • Like 1
Link to comment
Share on other sites

  • Ali Samie changed the title to [SOLVED] How to add hour:minute:second to the date filter in helperLists in prestashop?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...