引用:
作者: domainplayer
by the way,
其實資料裡有一個addtime的項目,
但每筆拍賣物的addtime數值都是像 1128664635 這樣的怪數字串,
請問這是不是mysql裡時間的特殊儲存格式?
若是的話該怎麼把它呼叫成正常的"年/月/日"? 
|
那串數字 1128664635 是 unix timestamp 的表示法
php 手冊上 time() function 中有一段:「
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). 」
可以用 date() 來轉換成人類讀得懂的格式,範例:
代碼:
<?php
$SubmitTime = 1128664635;
$HumanReadableTime = date( "Y-m-d", $SubmitTime);
echo $HumanReadableTime;
?>
可以用其它參數來更換出顯示的 format,詳情請查看 php manual 的 date() function
有關 MySQL 語法的話,樓上的青狼兄有解釋清楚了,建議可以買本書放在手邊方便查閱用
小弟推薦這本內容豊富也淺顯易懂的書: 入門 SQL
http://www.hot.net.tw/cgi-bin/introb...rderid=DB20066
或者是網路上的資源也很豊富