Skip to content

Commit

Permalink
Merge pull request smalot#231 from rbairwell/patch-1
Browse files Browse the repository at this point in the history
Add default timezone (UTC)
  • Loading branch information
smalot authored Mar 28, 2019
2 parents ec72a99 + ee2dae3 commit 0c85b15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Smalot/PdfParser/Element/ElementDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ public static function parse($content, Document $document = null, &$offset = 0)
}

$format = self::$formats[strlen($name)];
$date = \DateTime::createFromFormat($format, $name);
$date = \DateTime::createFromFormat($format, $name, new \DateTimeZone('UTC'));
} else {
// special cases
if (preg_match('/^\d{1,2}-\d{1,2}-\d{4},?\s+\d{2}:\d{2}:\d{2}[\+-]\d{4}$/', $name)) {
$name = str_replace(',', '', $name);
$format = 'n-j-Y H:i:sO';
$date = \DateTime::createFromFormat($format, $name);
$date = \DateTime::createFromFormat($format, $name, new \DateTimeZone('UTC'));
}
}

Expand Down

0 comments on commit 0c85b15

Please sign in to comment.