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 trialKaran Jindal
Courses Plus Student 1,406 PointsHow 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.
1 Answer
Logan R
22,989 PointsI 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);
Karan Jindal
Courses Plus Student 1,406 PointsKaran Jindal
Courses Plus Student 1,406 PointsYou can take the example of billing system where we choose specific date and the results are displayed accordingly.