Formatting MySQL timestamp to PHP DateTime
How can I forma开发者_Python百科t a timestamp from MySQL to a date value in PHP?
Formatting and storing of a date can be perfectly seperated. Use strotime
and strftime
to calculate timestamps and use those with date
.
In your view:
date('F d, Y at g a', strtotime($storedDate));
Wherever you store your date
date('Y-m-d H:i:s', strtotime($formattedData));
echo date('r', strtotime($mysql_datetime_column_value));
See the date() function in the PHP documentation for more detail.
精彩评论