S
S
strify_252020-11-13 21:16:17
1C-Bitrix
strify_25, 2020-11-13 21:16:17

How to select infoblock elements created in the last 24 hours?

Already tormented with this, I do everything as in the documentation, the time format is necessary, but it still does not return anything!

$arFilter = Array(
    "IBLOCK_ID"=>12, 
    array(
        '>=DATE_CREATE' => date( 'Y-m-d H:i:s', time()-86400 ),
        '<=DATE_CREATE' => date( 'Y-m-d H:i:s' )     
    ),
    "PROPERTY_PHONE"=>"+7 (333) 333-3333"
 );

$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, Array("ID"));
while($ar_fields = $res->GetNext())
{
    ?><pre><?print_r($ar_fields);?></pre><?
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2020-11-13
@strify_25

$from = date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")), 
mktime(0,0,0,date("m"),date("d"),date("Y")));
$to = date($DB->DateFormatToPHP(CSite::GetDateFormat("SHORT")), 
mktime(0,0,0,date("m"),date("d")+1,date("Y")));

">=CREATED_DATE" => $from,
"<=CREATED_DATE" => $to

--
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "CREATED_DATE", "PROPERTY_PHONE");
$res = CIBlockElement::GetList(Array("SORT"=>"ASC"), $arFilter, false, Array("nPageSize"=>50), $arSelect);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question