Posted on Leave a comment

MySQL datetime field by PHP

How to print datetime field

1.SQL:

select unix_timestamp(datetimefield) as dtf from table

PHP:

echo date('Y-m-d H:i', $r["dtf"]);

2.SQL:

select * from table

PHP:

$dt = date_create($r["datetimefield"]);
echo date_format($dt, 'Y-m-d H:i');

Read manual

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.