开发者

(php) date and time

开发者 https://www.devze.com 2022-12-27 10:43 出处:网络
How to get date and time into one string ($moment) and if it works, can mysql do this: SELECT * FROM table ORDER BY $m开发者_StackOverflowoment ASC

How to get date and time into one string ($moment) and if it works, can mysql do this:

SELECT * FROM table ORDER BY $m开发者_StackOverflowoment ASC ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消