Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

PHP & MYSQL: Closest Dates

SpaceshipSpaceship
NamecheapNamecheap
Namecheap AuctionsNamecheap Auctions
Watch

dcgamers

Established Member
Impact
1
How would I display all the data in a table where the date field is within 10 days above the current date? Im tring to display all dates within the next 10 days. How can I do that with php & mysql?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
So basicly you need to know two variables: today's date and date after 10 days.

Try adding this to WHERE clause:
Code:
... WHERE date > ADDDATE(CURRENT_DATE(), 0) AND date <= ADDDATE(CURRENT_DATE() , 10)
'date' is your date field.

Another way would be something like that:
Code:
$tendays = 60*60*24*10 // how many seconds in 10 days
$datenow = date("Y-m-d");
$date10 = date("Y-m-d", time() + $tendays); // this will be your date (10 days after)
Change Y-m-d to your date format. You can find information on how to do that here:
http://www.php.net/date
Then put date variables to your WHERE clause. Something like: ... WHERE date > $datenow and date <= $date10

I haven't checked the code for errors, I just wrote it. I hope this will be enough to get a general idea :)

Good luck!
 
Last edited:
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back