简体   繁体   中英

Change the date format using Carbon - Laravel

I have a date in my database which is 2018-05-21 00:00:00.00000 I would like to get the name of the month , I am trying to make the date as a carbon format (not sure if it is not) with this code

    `$timestemp = Carbon::create('Y-m-d H:i:s', $timestamp)->toFormattedDateString();`

and I am getting this error

Unexpected data found. Trailing data

If anyone have an alternative solution or know a fix for the issue please help me.

如果您想获得月份名称,请尝试使用以下代码

$timestemp = Carbon::parse($timestamp)->format('F');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM