Skip to content

Commit 34b728a

Browse files
authored
Merge pull request #65 from lewyckoff/master
Switch `Util.getTimestamp()` to always return values using UTC
2 parents 95f49d6 + a880fb9 commit 34b728a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Util.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static function getTimestamp() {
7272
$microseconds = sprintf('%06d', ($time - floor($time)) * 1000000);
7373
$millseconds = round($microseconds, -3)/1000;
7474
$millsecondsStr = str_pad($millseconds, 3, '0', STR_PAD_LEFT);
75-
$date = (new \DateTime())->format('c');
75+
$date = (new \DateTime(null, new \DateTimeZone("UTC")))->format('c');
7676

7777
$position = strrpos($date, '+');
7878
$date = substr($date,0,$position).'.'.$millsecondsStr.substr($date,$position);

tests/UtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function testGetTimestamp() {
3434
// catch regressions, at least more than will be accepted by an LRS which is really
3535
// ultimately what we want in our tests
3636
//
37-
$this->assertRegExp('/\d\d\d\d-[01]\d-[0123]\dT[012]\d:[012345]\d:[012345]\d\.\d\d\d[-+]\d\d:\d\d/', $result);
37+
$this->assertRegExp('/\d\d\d\d-[01]\d-[0123]\dT[012]\d:[012345]\d:[012345]\d\.\d\d\d\+00:00/', $result);
3838
}
3939
}

0 commit comments

Comments
 (0)