Convert a date format in PHP

后端 未结 18 2699
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 06:09

I am trying to convert a date from yyyy-mm-dd to dd-mm-yyyy (but not in SQL); however I don\'t know how the date function requires a timestamp, and

18条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-21 06:50

    You can change the format using the date() and the strtotime().

    $date = '9/18/2019';

    echo date('d-m-y',strtotime($date));

    Result:

    18-09-19

    We can change the format by changing the ( d-m-y ).

提交回复
热议问题