Php Carbon/DateTime:在数据库中找不到时区
我正在读取带有日期时间字段的CSV文件,但当我尝试通过执行Php Carbon/DateTime:在数据库中找不到时区,php,datetime,php-carbon,Php,Datetime,Php Carbon,我正在读取带有日期时间字段的CSV文件,但当我尝试通过执行$date=new Carbon($row['date'])将日期转换为Carbon时,我遇到以下错误之一: DateTime::__construct(): Failed to parse time string (09/07/2014 16:55:22 MEST) at position 20 (M): The timezone could not be found in the database DateTime::__const
$date=new Carbon($row['date'])
将日期转换为Carbon
时,我遇到以下错误之一:
DateTime::__construct(): Failed to parse time string (09/07/2014 16:55:22 MEST) at position 20 (M): The timezone could not be found in the database
DateTime::__construct(): Failed to parse time string (24/01/2014 16:57:27 MET) at position 0 (2): Unexpected character
PHP似乎无法识别MET/MEST时区。如何动态转换任何非标准时区以创建Carbon/DateTime对象?该格式可能不是可识别的格式。用这个代替。它只适用于MET,因为MEST不是
比我快。。这就是他需要的++那么我该怎么处理这些无效的格式呢?例如,我可能也会得到MEST或CEST(中欧夏季同一时区),PHP以外的一些系统将其视为有效时区。您可能需要创建一个可能性数组及其等价物,并使用它们来替换时区。希望有一些标准的方法来替换时区,但
str_replace(['MEST',CEST'],['MET',['CET'],$row['date'])
将不得不这样做。
$date = Carbon::createFromFormat('d/m/Y H:i:s T', $row['date']);