Skip to content

Commit 583881e

Browse files
committed
Use date_create() instead of DateTime constructor
1 parent cde4a28 commit 583881e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/main/php/util/Date.class.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public function __construct($in= null, TimeZone $timezone= null) {
5050
$this->handle= date_create('@'.$in);
5151
date_timezone_set($this->handle, $timezone ? $timezone->getHandle() : timezone_open(date_default_timezone_get()));
5252
} else {
53-
try {
54-
$this->handle= $timezone ? new \DateTime($in ?? 'now', $timezone->getHandle()) : new \DateTime($in ?? 'now');
55-
} catch (\Throwable $e) {
53+
if (false === ($this->handle= date_create($in ?? 'now', $timezone ? $timezone->getHandle() : null))) {
5654
throw new IllegalArgumentException('Given argument is neither a timestamp nor a well-formed timestring: '.Objects::stringOf($in));
5755
}
5856
}

0 commit comments

Comments
 (0)