公告
财富商城
积分规则
提问
发文
2018-12-31 05:11发布
梦该遗忘
I have a datetime column in MySQL.
datetime
How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?
Using PHP version 4.4.9 & MySQL 5.0, this worked for me:
$oDate = strtotime($row['PubDate']); $sDate = date("m/d/y",$oDate); echo $sDate
PubDate is the column in MySQL.
PubDate
This should format a field in an SQL query:
SELECT DATE_FORMAT( `fieldname` , '%d-%m-%Y' ) FROM tablename
Forget all. Just use:
$date = date("Y-m-d H:i:s",strtotime(str_replace('/','-',$date)))
You can have trouble with dates not returned in Unix Timestamp, so this works for me...
return date("F j, Y g:i a", strtotime(substr($datestring, 0, 15)))
If you are using PHP 5, you can also try
$oDate = new DateTime($row->createdate); $sDate = $oDate->format("Y-m-d H:i:s");
This will work...
echo date('m/d/y H:i (A)',strtotime($data_from_mysql));
最多设置5个标签!
Using PHP version 4.4.9 & MySQL 5.0, this worked for me:
PubDate
is the column in MySQL.This should format a field in an SQL query:
Forget all. Just use:
You can have trouble with dates not returned in Unix Timestamp, so this works for me...
If you are using PHP 5, you can also try
This will work...