为什么 Carbon toDatetimeString 没有返回预期的格式?
Why Carbon toDatetimeString is not returning the expected format?
从文档中我看到:
echo $dt->toDateTimeString(); // 1975-12-25 14:15:16
但实际上,如果我放弃我的执行,我得到:
$now = Carbon::now()->toDayDateTimeString();
dump($now); //Mon, Oct 2, 2017 12:49 PM
我需要:
$now = Carbon::now()->format('Y-m-d H:i:s');
为了得到:
dump($now); //2017-10-02 12:49:06
我错过了什么?
尝试将字符串格式重置为默认值:
Carbon::resetToStringFormat()
那么 Carbon::now()->toDateTimeString()
应该会给你想要的东西。
从文档中我看到:
echo $dt->toDateTimeString(); // 1975-12-25 14:15:16
但实际上,如果我放弃我的执行,我得到:
$now = Carbon::now()->toDayDateTimeString();
dump($now); //Mon, Oct 2, 2017 12:49 PM
我需要:
$now = Carbon::now()->format('Y-m-d H:i:s');
为了得到:
dump($now); //2017-10-02 12:49:06
我错过了什么?
尝试将字符串格式重置为默认值:
Carbon::resetToStringFormat()
那么 Carbon::now()->toDateTimeString()
应该会给你想要的东西。