diff --git a/src/LegacyEventMapper.php b/src/LegacyEventMapper.php index 77f57a2a..cb452d02 100644 --- a/src/LegacyEventMapper.php +++ b/src/LegacyEventMapper.php @@ -193,7 +193,7 @@ private function convertRawPubsubPayload(array $jsonData, string $requestUriPath if (array_key_exists('publishTime', $jsonData['message'])) { $timestamp = $jsonData['message']['publishTime']; } else { - $timestamp = gmdate('%Y-%m-%dT%H:%M:%S.%6NZ'); + $timestamp = gmdate('Y-m-d\TH:i:s.v\Z'); } return [ diff --git a/tests/LegacyEventMapperTest.php b/tests/LegacyEventMapperTest.php index 2a3dda7d..00511757 100644 --- a/tests/LegacyEventMapperTest.php +++ b/tests/LegacyEventMapperTest.php @@ -128,7 +128,7 @@ public function testRawPubsubNoPath(): void ); $this->assertNull($cloudevent->getSubject()); $this->assertEqualsWithDelta( - strtotime(gmdate('%Y-%m-%dT%H:%M:%S.%6NZ')), + strtotime(gmdate('Y-m-d\TH:i:s.v\Z')), strtotime($cloudevent->getTime()), 1 ); @@ -168,7 +168,7 @@ public function testRawPubsubWithPath(): void ); $this->assertNull($cloudevent->getSubject()); $this->assertEqualsWithDelta( - strtotime(gmdate('%Y-%m-%dT%H:%M:%S.%6NZ')), + strtotime(gmdate('Y-m-d\TH:i:s.v\Z')), strtotime($cloudevent->getTime()), 1 );