我已使用CURRENT_TIMESTAMP
將當前日期和時間添加到我的數據庫中。當前時間和日期
然而,當我贊同此日期/時間它顯示在下面的格式
2013年10月4日13時53分47秒
有沒有辦法來此格式更改爲
2013年4月10日13:53
由於
我已使用CURRENT_TIMESTAMP
將當前日期和時間添加到我的數據庫中。當前時間和日期
然而,當我贊同此日期/時間它顯示在下面的格式
2013年10月4日13時53分47秒
有沒有辦法來此格式更改爲
2013年4月10日13:53
由於
如果你使用MySQL,您可以更改顯示日期的方式與DATE_FORMAT()
SELECT column1,
column2,
date_format(date_column, '%d-%m-%Y %h:%i') as formatted_date,
othercolumn
from blogposts
,您可以選擇您的日期包裹在DATE_FORMAT(日期格式)。
點擊此處瞭解詳情:
嘗試strf_time()。如果它不起作用,你總是可以使用explode()這個字符串。
<?php
$datefromDB;
$dateyourequired = date('Y-m-d H:i', strtotime($datefromDB));
echo $dateyourequired;
?>
請https://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#看看了'Date_format'功能,文檔function_date格式。另外,在提出問題之前,請進行更多的研究工作,這可以很容易地被Google搜索到。 – dirkk