Posted on

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

Your email address will not be published. Required fields are marked *