tags:

views:

43

answers:

1

(php) how to get date and time into one string ($moment) and if it works, can mysql do this: SELECT * FROM table ORDER BY moment ASC ?

+1  A: 

Assuming you have a TIMESTAMP or a DATETIME column, then the date() function will give you a suitable value to use in a query:

$moment = date("Y-m-d H:i:s");  //current time

The query you put in your question doesn't seem to use it at all however. Using ORDER BY on a datetime/timestamp column does work though, so you'll get the result set in chronological order.

zombat
okay so if i want to order comments by example, they will be ordered chronologically automatically?
linkcool
If you put an `ORDER BY someDateOrTimeColumn` into your query, then yes, MySQL handles the ordering for you.
zombat