Skip to content

Commit bc908ff

Browse files
committed
DateTime: refactoring
1 parent a5fe153 commit bc908ff

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Utils/DateTime.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ public static function createFromFormat(
9696
string|\DateTimeZone|null $timezone = null,
9797
): static|false
9898
{
99-
if ($timezone === null) {
100-
$timezone = new \DateTimeZone(date_default_timezone_get());
101-
102-
} elseif (is_string($timezone)) {
99+
if (is_string($timezone)) {
103100
$timezone = new \DateTimeZone($timezone);
104101
}
105102

@@ -149,7 +146,7 @@ public function setTime(int $hour, int $minute, int $second = 0, int $microsecon
149146
*/
150147
public static function relativeToSeconds(string $relativeTime): int
151148
{
152-
return (new \DateTimeImmutable('1970-01-01 ' . $relativeTime, new \DateTimeZone('UTC')))
149+
return (new \DateTimeImmutable('@0 ' . $relativeTime, new \DateTimeZone('UTC')))
153150
->getTimestamp();
154151
}
155152

0 commit comments

Comments
 (0)