Jump to content

How do I filter out dates in PHP?


lpxxfaintxx

Recommended Posts

I have a database of events that have a table 'date' that has dates stored in the format "Month Day, Year." How would I make make a query that only selects dates that are in the future, and not past?

 

For example, today is February 9, 2009. Let's say I have the following rows with the 'date' tables:

 

January 4, 2009

January 31, 2009

February 21, 2009

February 26, 2009

 

How would I make it so that I only get "February 21, 2009" and "February 26, 2009," since they are UPCOMING, and not in the past?

 

Hope that makes sense. thanks

Link to comment
https://forums.phpfreaks.com/topic/144580-how-do-i-filter-out-dates-in-php/
Share on other sites

Thanks, I will look into that. What is the date format for MySQL? Is it YYYY-MM-DD?

 

Also, when I echo out the date in PHP, how do I make the date more "user-friendly?" IE, how do I make it show up as "February 24, 2009" instead of "2009-02-24"

 

After I change the column to date, then what do I do? Any query to get the dates in the future?

 

If you use any of the database date or time formats, then in your select use DATE_FORMAT() to format the return, example...

 

SELECT DATE_FORMAT(date_column, '%M %e, %Y') AS date_column FROM ...

// output example

$row['date_column'] = January 1, 2009

 

 

DATE_FORMAT Reference

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.