Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 99e722d

Browse files
committed
Merge pull request #154
2 parents 0d94cff + f78a3f0 commit 99e722d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

ext_mongodb.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,13 +1704,10 @@ public function serialize() : string
17041704

17051705
public function jsonSerialize() : mixed
17061706
{
1707-
$seconds = (int) ( $this->milliseconds / 1000 );
1708-
$millis = (int) ( $this->milliseconds % 1000 );
1709-
1710-
$d = date_create( "@" . (string) $seconds );
1711-
17121707
return [
1713-
'$date' => sprintf( "%s.%03d+0000", $d->format( 'Y-m-d\TH:i:s' ), $millis )
1708+
'$date' => [
1709+
'$numberLong' => (string) $this->milliseconds,
1710+
],
17141711
];
17151712
}
17161713

tests/json-serialize-utcdatetime.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var_dump( \MongoDB\BSON\toPHP( \MongoDB\BSON\fromJSON( $d ) ) );
1414
?>
1515
--EXPECTF--
1616
{ "foo" : { "$date" : 1476192866817 } }
17-
{"foo":{"$date":"2016-10-11T13:34:26.817+0000"}}
17+
{"foo":{"$date":{"$numberLong":"1476192866817"}}}
1818
object(stdClass)#%d (%d) {
1919
["foo"]=>
2020
object(MongoDB\BSON\UTCDateTime)#%d (%d) {

0 commit comments

Comments
 (0)