How to get Current Timestamp from Carbon in Laravel 5

前端 未结 7 1769
天涯浪人
天涯浪人 2021-02-01 01:05

I want to get current timestamp in laravel 5 and I have done this-

$current_time = Carbon\\Carbon::now()->toDateTimeString();

I am getting e

7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-01 01:08

    You need to add another \ before your carbon class to start in the root namespace.

    $current_time = \Carbon\Carbon::now()->toDateTimeString();
    

    Also, make sure Carbon is loaded in your composer.json.

提交回复
热议问题