简体   繁体   English

使用Carbon - Laravel更改日期格式

[英]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 我在我的数据库中有一个日期是2018-05-21 00:00:00.00000我想得到月份的名称,我想把日期作为碳格式(不确定是不是)与这段代码

    `$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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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