函数名:MongoDB\BSON\Timestamp::__construct()
功能:创建一个新的MongoDB\BSON\Timestamp对象。
参数:
- $increment:一个32位整数,表示时间戳的递增部分。
- $timestamp:一个32位整数,表示时间戳的秒部分。
返回值:一个新的MongoDB\BSON\Timestamp对象。
适用版本:MongoDB\BSON\Timestamp::__construct()函数在MongoDB扩展版本1.4.0及以上版本中可用。
示例:
// 创建一个新的MongoDB\BSON\Timestamp对象
$timestamp = new MongoDB\BSON\Timestamp(1, 1627286400);
// 输出MongoDB\BSON\Timestamp对象
var_dump($timestamp);
/*
输出结果:
object(MongoDB\BSON\Timestamp)#1 (2) {
["increment"]=>
int(1)
["timestamp"]=>
int(1627286400)
}
*/
在上面的示例中,我们使用MongoDB\BSON\Timestamp::__construct()函数创建了一个新的MongoDB\BSON\Timestamp对象。该对象具有递增部分为1,时间戳为1627286400。通过var_dump()函数输出该对象的内容,可以看到对象的increment属性为1,timestamp属性为1627286400。