eComEvo
eComEvo

Reputation: 12559

Carbon/DateTime: The timezone could not be found in the database

I'm reading a CSV file with datetime fields but when I try to convert the date to Carbon by doing $date = new Carbon($row['date']) I get one of these errors:

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

Seems PHP does not recognize the MET/MEST timezones. How can I dynamically convert any non-standard timezones to create a Carbon/DateTime object?

Upvotes: 3

Views: 22274

Answers (1)

aynber
aynber

Reputation: 23011

The format may not be in a recognizable format. Use this instead. It will only work with MET, as MEST is not a valid timezone

$date = Carbon::createFromFormat('d/m/Y H:i:s T', $row['date']);

Upvotes: 4

Related Questions