Last active
October 18, 2019 15:26
-
-
Save isotrope/f836750c6fa64186a8d16021147149a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query_args = array( | |
'meta_query' => array( | |
// relation between time query and online query | |
'relation' => 'OR', | |
// time query | |
array( | |
// relation for time query | |
'relation' => 'AND', | |
array( | |
'key' => 'start_time', | |
'value' => '20191018100000', | |
'compare' => '>=', | |
), | |
array( | |
'key' => 'end_time', | |
'value' => '20191018120000', | |
'compare' => '<=', | |
), | |
), | |
// online query | |
array( | |
'key' => 'online', | |
'value' => 'true', | |
'compare' => '=', | |
), | |
), // end meta_query | |
); |
This seems to work:
$meta_query['time-range'] = $meta_query['time-range'] = array(
'relation' => 'AND',
array(
'key' => 'hsucs_start_time',
'value' => array( '00:00:01', $t['start'] . ':00' ),
'compare' => 'NOT BETWEEN',
),
array(
'key' => 'hsucs_end_time',
'value' => array( $t['end'] . ':00', '23:59:59' ),
'compare' => 'NOT BETWEEN',
)
);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Almost; except that
start_time
andend_time
are time values, not full datetime values, so, thevalue
would look more like12:00:00
or13:59:48
, and thetype
parameter for those 2 queries is set toTIME
.So:
becomes: