(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
2010-04-14 18:54:09
okay so if i want to order comments by example, they will be ordered chronologically automatically?
linkcool
2010-04-14 19:03:49
If you put an `ORDER BY someDateOrTimeColumn` into your query, then yes, MySQL handles the ordering for you.
zombat
2010-04-14 19:12:26