mysql提供了兩個函數:
from_unixtime(time_stamp) -> 將時間戳轉換為日期 unix_timestamp(date) -> 將指定的日期或者日期字符串轉換為時間戳
如果要查詢當天的訂單的記錄: [plain] select count(*) from b_order Where date_format(from_unixtime(create_time),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d') 也可以這樣: [plain] select count(*) from b_order Where create_time >= unix_timestamp('2013-10-24 00:00:00') and create_time <= unix_timestamp('2013-10-24 23:59:59') ;