Convert DateTime to String PHP

后端 未结 6 1933
醉梦人生
醉梦人生 2020-11-30 18:27

I have already researched a lot of site on how can I convert PHP DateTime object to String. I always see \"String to DateTime\" and not \"DateTime to String\"

PHP D

6条回答
  •  忘掉有多难
    2020-11-30 18:46

    Shorter way using list. And you can do what you want with each date component.

    list($day,$month,$year,$hour,$min,$sec) = explode("/",date('d/m/Y/h/i/s'));
    echo $month.'/'.$day.'/'.$year.' '.$hour.':'.$min.':'.$sec;
    

提交回复
热议问题