这对某些人来说很简单;
我有时间:June, 18 2021 21:33
如何在 PHP 中转换为 2021-06-18 21:33:00
。
我试过了:
$send_time = "June, 18 2021 21:33";
$date = Carbon::parse($send_time);
echo $date->format('Y-m-d h:i:sa');
然后得到 Could not parse 'June, 18 2021 21:33': DateTime::__construct(): Failed to parse time string (June, 18 2021 21:33) at position 6 (1): Unexpected character
答案 0 :(得分:0)
那个日期时间不是任何标准格式。您将必须创建自己的格式才能传入:
$date = Carbon::createFromFormat('F, d Y H:i', $send_time);
请参阅 https://www.php.net/manual/en/datetime.format.php 了解所有日期格式字符