Accept all valid date formats

This commit is contained in:
Abhishek Kumar
2023-01-18 19:52:39 +05:30
parent 3e49492af7
commit 2ec01dbc49
3 changed files with 14 additions and 6 deletions

View File

@@ -92,11 +92,15 @@ class ProductControllerCore extends FrontController
$dateFrom = Tools::getValue('date_from');
$dateTo = Tools::getValue('date_to');
if ($dateFrom != '' && !Validate::isDate($dateFrom)) {
$currentTimestamp = strtotime(date('Y-m-d'));
$dateFromTimestamp = strtotime($dateFrom);
$dateToTimestamp = strtotime($dateTo);
if ($dateFrom != '' && (!$dateFromTimestamp || ($dateFromTimestamp < $currentTimestamp))) {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
}
if ($dateTo != '' && !Validate::isDate($dateTo)) {
if ($dateTo != '' && (!$dateToTimestamp || ($dateToTimestamp < $currentTimestamp))) {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
}