Re: dealing with dates

From: Date: Tue, 04 Mar 2003 08:02:17 +0000
Subject: Re: dealing with dates
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138031@lists.php.net to get a copy of this message
you should make the column for the time posted in your table to be Date/time. mysql stores it in this format: 2003-02-24 12:43:45 (year-month-day hours:minutes:seconds) to allow the current date/time to be inserted into this column date("Y-m-d G:i:s") if you want to DISPLAY it in this date format (mm/dd/yy), then anytime you query the table, just add say for example, DATE_FORMAT(Posted, '%c/%e/%y') as datePosted where Posted is column name in your table, and datePosted is the new variable you want to assign the date to. to answer your second question to get a records between 2 dates, it's simply adding this to your query: ...where datePosted BETWEEN '$startthedate' and '$endthedate' Hope this helped. for more on dates, check out this link: http://www.php.net/manual/en/function.date.php "Charles Kline" <ckline@rightcode.net> wrote in message news:9B8AECE0-4DF2-11D7-B7C3-000393CDCA6A@rightcode.net... > Hi all, > > I posted earlier with some date questions, but realized I could > probably do better with my question presented as such. > > I need to save the time date and time of posting for the records in a > table. > I then need to be able to search via a startdate and enddate text field > where the user will be entering the date ranges as mm/dd/yyyy. > > What is the best way to handle adding the date to the MySQL record, and > also how to search for that date based on a range in the above stated > format? > > Thanks, > Charles >

« previous php.general (#138031) next »