duanshan2988 2016-09-12 06:36
浏览 81
已采纳

如何从php中的phpmyadmin获取日期(d,m,y)? [重复]

This question already has an answer here:

I want to fetch date format from (y,m,d) to (d,m,y).In my database I already insert data like date and images so many around 400 images.I dun want to insert again.phpmyadmin

The following is to fetch from database.

<?              
                            $sql = "SELECT * FROM  ShowFillter GROUP BY Image_Date order by Image_Date desc";
                            $objQuery = mysql_query($sql) or die ("Error Query [".$sql."]");
                            while($objResult1 = mysql_fetch_array($objQuery))
                            {
                        ?>
                        <li class="filter" data-filter="<?=$objResult1['Image_Date'];?>">
                            <a href="#">
                                <?=$objResult1['Image_Date'];?></a>
                        </li>

                        <? 
                            }    
                        ?>

The following is i tried it out to fetch from database.But It only show (Year ,Month,day) format.

<?              
                            $sql = "SELECT * FROM  ShowFillter GROUP BY DATE_FORMAT(Image_Date, '%d/%m/%Y') order by DATE_FORMAT(Image_Date, '%d/%m/%Y') desc";
                            $objQuery = mysql_query($sql) or die ("Error Query [".$sql."]");
                            while($objResult1 = mysql_fetch_array($objQuery))
                            {
                        ?>
                        <li class="filter" data-filter="<?=$objResult1['Image_Date'];?>">
                            <a href="#">
                                <?=$objResult1['Image_Date'];?></a>
                        </li>

                        <? 
                            }    
                        ?>

Here is the result result Is it possible to fetch (day,month,year) format? If its possible ,guide me please.

Thanks :)

</div>
  • 写回答

3条回答 默认 最新

  • dtdfj08626 2016-09-12 06:44
    关注

    When you print your image date do:

    <?=date('d-m-Y', strtotime($objResult1['Image_Date])); ?>
    

    This will echo 27-12-2013

    More here http://php.net/manual/en/function.date.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 github符合条件20分钟秒到账,github空投 提供github账号可兑换💰感兴趣的可以找我交流一下
  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?