下面的代码旨在在执行自定义 wordpress 查询之前查找接下来 3 周的第 5 天(星期五)和第 6 天(星期六)。出于某种原因,我无法让它添加第 6 天。
请问有什么想法吗?
/* We need this to start on a Friday */
$datDate = date( 'Y-m-d' );
while( date('w', strtotime( $datDate ) ) != 5 ) {
$datDate = date( 'Y-m-d', strtotime( $datDate . " +1 DAY" ) );
}
/* This is over 3 weeks, so we need 3 arrays of all available days */
$arrDate1[] = "'".$datDate . " 00:00:00'";
for( $i = 1; $i < 7; $i++ ) {
$datDate = date( 'Y-m-d', strtotime( $datDate . " +1 DAY" ) );
$arrDate1[] = "'".$datDate ." 00:00:00'";
}
/* Ok, create a new array and add another 7 days */
for( $i = 1; $i <= 7; $i++ ) {
$datDate = date( 'Y-m-d', strtotime( $datDate . " +1 DAY" ) );
$arrDate2[] = "'".$datDate . " 00:00:00'";
}
/* Same again for our third array */
for( $i = 1; $i <= 7; $i++ ) {
$datDate = date( 'Y-m-d', strtotime( $datDate . " +1 DAY" ) );
$arrDate3[] = "'".$datDate . " 00:00:00'";
}
/* Convert our 3 dates to comma seperates strings for the IN QUERY */
$strDate1 = implode(",",$arrDate1);
$strDate2 = implode(",",$arrDate2);
$strDate3 = implode(",",$arrDate3);
$strQuery = "