ID = absint( $post->ID ); $this->post = $post; else: $this->ID = absint( $post ); $this->post = get_post( $this->ID ); endif; } public function range( $where = '', $format = 'Y-m-d' ) { $datetimezone = new DateTimeZone( sp_get_timezone() ); $from = new DateTime( $this->from, $datetimezone ); $to = new DateTime( $this->to, $datetimezone ); $to->modify( '+1 day' ); $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'"; return $where; } public function relative( $where = '', $format = 'Y-m-d' ) { $datetimezone = new DateTimeZone( sp_get_timezone() ); $from = new DateTime( 'now', $datetimezone ); $to = new DateTime( 'now', $datetimezone ); $from->modify( '-' . abs( (int) $this->past ) . ' day' ); $to->modify( '+' . abs( (int) $this->future ) . ' day' ); $to->modify( '+1 day' ); $where .= " AND post_date BETWEEN '" . $from->format( $format ) . "' AND '" . $to->format( $format ) . "'"; return $where; } }