Skip to content

Commit 9467b88

Browse files
authored
Fixes Y-d-m format
In some cases, Y-d-m is returned for setDeathday (ex. person Tmdb ID 1081524). DateTime::__construct(): Failed to parse time string (1-16-2016) at position 0 (1): Unexpected character
1 parent 25bf656 commit 9467b88

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/Tmdb/Model/Person.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,12 @@ public function getChanges()
265265
public function setDeathday($deathday)
266266
{
267267
if (!$deathday instanceof \DateTime && !empty($deathday)) {
268-
$deathday = new \DateTime($deathday);
268+
// Is the format Y-m-d ?
269+
if(strtotime($deathday) === false) {
270+
$deathday = \DateTime::createFromFormat('Y-d-m', $deathday);
271+
} else {
272+
$deathday = new \DateTime($deathday);
273+
}
269274
}
270275

271276
if (empty($deathday)) {

0 commit comments

Comments
 (0)