dongtun1683 2017-03-27 07:09 采纳率: 0%
浏览 87
已采纳

如何在PHP中将日期从yyyy-mm-dd转换为dd-mm-yyyy? [重复]

This question already has an answer here:

I am storing date in yyyy-mm-dd in database. Now i want to display that date in frontend but while displaying date it should be in dd-mm-yyyy format. How to display it in this format please help <?php echo $data2['emp_dob'];?> . I dont want to change my current format of storing date in yyyy-mm-dd. please help me to display it in dd-mm-yyyy format only

</div>
  • 写回答

6条回答 默认 最新

  • dongya4335 2017-03-27 07:16
    关注

    use this function, which uses inbuilt function 'substr(str,start,length)'.

    function getFormatDate($date){
        $date = substr($date,8,2).'-'.substr($date,5,2).'-'.substr($date,0,4);
        return $date;
    }
    
    getFormatDate($data2['emp_dob']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?