Re: mysql date/time question

From: Date: Sun, 01 Feb 2004 19:55:30 +0000
Subject: Re: mysql date/time question
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-32742@lists.php.net to get a copy of this message
js wrote:
ok, 2 questions. first, how do i do a mysql query that orders by date? like this? $newestquery = "SELECT artid,title,artdate,artauthor FROM article WHERE artdate <= $today ORDER BY artdate DESC LIMIT 5";
Honestly, you could have taken the two seconds to try that and see if it worked instead of asking and waiting for an answer from a mailing list.
and also, my next question is how do i format the display of date and time from how MySQL stores it
Use DATE_FORMAT() in your query. It's a MySQL function, so see the manual for the syntax. It's in chapter... crap.. they changed the chapter numbers recently... chapter 12.4. Either that or use strtotime() on the MySQL date format to convert it into a unix timestamp and use the PHP date() function. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.db (#32742) next »