简体   繁体   中英

convert timestamp to date/hour/minute from database to datatable php mysql

I have timestamp saved in mysql database and i want it to be converted to date and hours and minutes and be displayed in a datatable like that (1375628707) want it -> 12/8/2013 (21:36:10)

<?php
                while ($row = mysql_fetch_array($result)) {
                    ?>
                    <tr>
                        <td><?=$row['ext']?></td>
                        <td><?=$row['user_id']?></td>
                        <td><a title="<?=$row['image_description']?>"> <?=$row['image_name']?> </a> </td>
                        <td><?=$row['upload_time']?></td>
                        <td><?=$row['image_id']?></td>
                        <td><a id="download" href="<?=$row['download_link']?>"><img src="download.png"></a></td>

                    <?php
                }
                ?>

i don't know what to add to the line

<td><?=$row['upload_time']?></td>

to be converted to real time

只需使用PHP标准date函数

<td><?= date('d/m/Y (H:i:s)', $row['upload_time']) ?></td>

一种选择是在查询中执行

.. DATE_FORMAT(upload_time,'%D %M %Y at %l:%i%p')as upload_time ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM