Tuesday, 13 August 2013

Wordpress adding extra day

Wordpress adding extra day

The code below is meant to look for day 5 (friday) and day 6 (saturday)
for the next 3 weeks before it does a custom wordpress query. For some
reason i just can't get it to add day 6.
Any ideas please?
/* 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 = "

No comments:

Post a Comment