Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Karan Jindal
PLUS
Karan Jindal
Courses Plus Student 1,406 Points

How to filter content on a page date wise?

Hi, I want to know: How to filter content on the basis date , month and year where the data is being fetched from the database.

Karan Jindal
Karan Jindal
Courses Plus Student 1,406 Points

You can take the example of billing system where we choose specific date and the results are displayed accordingly.

1 Answer

Logan R
Logan R
22,989 Points

I would suggest storing the date as a time() [http://php.net/manual/en/function.time.php] and sorting the SQL by time.

SQL is rusty, but something like:

Select date from table
ORDER BY date ASC

Edit: A link that provides an extended answer: http://www.w3schools.com/sql/sql_orderby.asp

You can convert time() into a date using the date() [http://php.net/manual/en/function.date.php] function.

string date ( string $format [, int $timestamp = time() ] )

date("d m y", 78299428934);