Convert DateTime to String PHP

后端 未结 6 1925
醉梦人生
醉梦人生 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:59

    Its worked for me

    $start_time   = date_create_from_format('Y-m-d H:i:s', $start_time);
    $current_date = new DateTime();
    $diff         = $start_time->diff($current_date);
    $aa           = (string)$diff->format('%R%a');
    echo gettype($aa);
    

提交回复
热议问题