Skip to content

Commit e65d114

Browse files
committed
Merge pull request #1010
2 parents 023c292 + 15a1cdc commit e65d114

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
MongoDB\BSON\ObjectId::getTimestamp: Ensure that the Timestamp field is represented as an unsigned 32-bit integer
3+
--FILE--
4+
<?php
5+
date_default_timezone_set("UTC");
6+
7+
function create_object_id($oid_string)
8+
{
9+
$objectid = new MongoDB\BSON\ObjectId($oid_string);
10+
$ts = sprintf("%u", $objectid->getTimestamp());
11+
echo $ts, "\n";
12+
echo date_create("@{$ts}")->format("Y-m-d H:i:s"), "\n";
13+
}
14+
15+
create_object_id('000000000000000000000000');
16+
create_object_id('7FFFFFFF0000000000000000');
17+
create_object_id('800000000000000000000000');
18+
create_object_id('FFFFFFFF0000000000000000');
19+
20+
?>
21+
--EXPECT--
22+
0
23+
1970-01-01 00:00:00
24+
2147483647
25+
2038-01-19 03:14:07
26+
2147483648
27+
2038-01-19 03:14:08
28+
4294967295
29+
2106-02-07 06:28:15

0 commit comments

Comments
 (0)