使用Carbon - Laravel更改日期格式

问题描述 投票:0回答:1

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

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

我收到了这个错误

Unexpected data found. Trailing data

如果有人有替代解决方案或知道问题的解决方案,请帮助我。

php laravel php-carbon
1个回答
0
投票

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

$timestemp = Carbon::parse($timestamp)->format('F');
© www.soinside.com 2019 - 2024. All rights reserved.