基本上我在找一個時間戳字段從轉換:2012-03-14 23:14:58
格式的(更易讀)23:14 pm March 15, 2012
轉換MySQL的時間戳更可讀的格式
我已經通過這個tutorial,但是我真的無法讓我的頭靠近它。我已經包含了我用來解析MySQL數據庫數據到Android應用程序的當前PHP腳本。
<?php
$con = mysql_connect("*******", "*******", "*******");
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("bluebase", $con);
$q=mysql_query("SELECT * from Comments where Category = 'General' ORDER BY Timestamp DESC");
while($e=mysql_fetch_assoc($q))
$output['General'][]=$e;
print(json_encode($output));
mysql_close();
>
23:14 pm是冗餘冗餘。你不想要11點14分? – 2012-03-15 13:53:49
你也可以使用MySQL的DATE_FORMAT函數 - http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format – Devart 2012-03-15 13:57:14
重複的[什麼是最簡單的方法從PHP中的SQL格式化時間戳?](http://stackoverflow.com/questions/238071/what-is-the-simplest-way-to-format-a-timestamp-from-sql-in-php) – 2012-03-15 14:02:45