Re: mysql date/time question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux