Php 按日期筛选表格条目
我试图在两个特定日期之间过滤(显示)网站前端的重力表单条目。一个是今天(当前日期),另一个是在网站后端添加的自定义日期 因此,仅限在自定义日期和当前日期之间提交的条目 我有两个变量存储这些日期:Php 按日期筛选表格条目,php,wordpress,gravity-forms-plugin,Php,Wordpress,Gravity Forms Plugin,我试图在两个特定日期之间过滤(显示)网站前端的重力表单条目。一个是今天(当前日期),另一个是在网站后端添加的自定义日期 因此,仅限在自定义日期和当前日期之间提交的条目 我有两个变量存储这些日期: $new\u start\u date是自定义日期,并且 $end_date是当前日期 我的代码输出200个条目,但其中一些在自定义开始日期之前 下面是我的查询代码: <?php //Get the Form ID to get the entries from and store it with
$new\u start\u date
是自定义日期,并且
$end_date
是当前日期
我的代码输出200个条目,但其中一些在自定义开始日期之前
下面是我的查询代码:
<?php
//Get the Form ID to get the entries from and store it within a varibale
$form_id = GFAPI::get_form(2);
// Get Dates
$date_page_id = get_field( 'update_dates_page_link', 'options', false, false );
$start_date = get_field( 'oak_submission_date', $date_page_id ); // date of the last submission date
$end_date = date( 'Y-m-d', time() ); //get today's date
// Convert start_date to match end_date format
$new_start_date = DateTime::createFromFormat( 'd/m/Y', $start_date );
$new_start_date = $new_start_date->format( 'Y-m-d' );
$search_criteria = array(
'status' => 'active',
'start_date' => $new_start_date,
'end_date' => $end_date,
'field_filters' => array(
array(
'key' => '53', // Trust name field
'value' => 'Oak Trust',
),
array(
'key' => '49', // Grant Made field
'value' => 'No',
),
),
);
$sorting = null;
$paging = array( 'offset' => 0, 'page_size' => 200 );
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging );
GFAPI::get_表单(2)不返回表单ID,而是返回表单。试试这个:
$entries = GFAPI::get_entries( 2, $search_criteria, $sorting, $paging );
$entries = GFAPI::get_entries( 2, $search_criteria, $sorting, $paging );