Y
Y
Yura Komarov2018-12-06 11:51:37
1C-Bitrix
Yura Komarov, 2018-12-06 11:51:37

How to display news in one day?

Hello everybody. I have a news page. I send a request with a get parameter and specify the dates in it.
Request like ?from=11/21/2018&to=11/23/2018.
On the same page I get this date and add it to the filter.

global $arrFilter; $arrFilter = array();
    if ($dateStart && $dateEnd && $dateStart != $dateEnd){
      $arrFilter[] = array(
        "LOGIC" => "AND",
        array(">=DATE_ACTIVE_FROM" => $dateStart),
        array("<=DATE_ACTIVE_FROM" => $dateEnd),
      );
    }else if($dateStart && $dateEnd && $dateStart == $dateEnd) {
      echo $dateEnd;
      // $dateStart
      $arrFilter[] = array(
        "LOGIC" => "AND",
        array(">=DATE_ACTIVE_FROM" => '21.11.2018'),
        array("<=DATE_ACTIVE_FROM" => '23.11.2018'),
      );
     // так сработает, но это я сделал для того что бы убедиться в том что вообще работает. 
    }

In the first part of the condition, everything works as it should, I get all the news from the gap.
The question is how to set the correct condition in the second part of the if to receive news for one day?
I've tried a lot of things and it doesn't work.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question