dragonpeng200811111 2014-04-14 07:04
浏览 116

如何转换yyyy mm dd h:m:s到dd mm yyyy h:m:s? [重复]

This question already has an answer here:

            In mysql data base the date is f=stored in the format of now() function like yyyy mm dd hh mm ss. But in frontend tool i want it like dd mm yyyy hh mm ss how can i convert it.


<?php 
 $addqry=mysql_query("INSERT INTO `exam`    (`user_id`,`sub_id`,`q_id`,`stud_ans`,`date_time`)VALUES ('$user', '$sub', '$ans', '$stud_ans',(Now()))");      
    $stud_ans=' ';                              
            if($addqry)
            {
            //result
            $date;
            $last_date=mysql_query("SELECT date_time FROM exam ORDER BY id DESC LIMIT 1; ");
            while($res_last=mysql_fetch_array($last_date))
            {
            $date=$res_last['date_time'];
            }
            ?>

Here it gives the datetime in the format of 2014-04-12 15:34:40 but i want it like 12-04-2014 15:34:40

</div>
  • 写回答

5条回答 默认 最新

  • doutiao2540 2014-04-14 07:06
    关注

    try

    $date=date('d-m-Y H:i:s', strtotime($res_last['date_time']));
    

    for more :- http://php.net/manual/en/function.date.php

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?