Jump to content

Display by Date


JSHINER

Recommended Posts

Sorry - should have included that:

 

I have a field "date" and the date is entered by the user in the 00/00/2007 format.

 

I need a page that will display results that are either the current date, or future dates.

 

is the date stored as in DATE format in the DB or as a VARCHAR?

Link to comment
https://forums.phpfreaks.com/topic/43720-display-by-date/#findComment-212268
Share on other sites

It can be stored as either - I haven't created it yet.

 

So low range - how can I have that be the current date?

 

$low_range =  date("Y-m-d"); //will set the low range to the current date, formatted in yyyy-mm-dd format (which is standard for mysql db's anyway)

 

You can still allow the users who do the inputting to enter their dates in mm-dd-yy format if you want, and reformat it before inserting it, into the DB, thats the method i use personally.

 

$low_range =  date("Y-m-d");
$sql='SELECT * FROM `db_name` WHERE `date_field` >= "'.$low_range.'" ORDER BY `date_field` DESC'; 

 

Link to comment
https://forums.phpfreaks.com/topic/43720-display-by-date/#findComment-212279
Share on other sites

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.