The MongoDB\BSON\Timestamp class

- « MongoDB\BSON\Regex::__toString

- MongoDB\BSON\Timestamp::__construct »

- PHP Manual
- MongoDB\BSON
- The MongoDB\BSON\Timestamp class

# The MongoDB\BSON\Timestamp class

(mongodb >=1.0.0)

## Introduction

Represents a » BSON timestamp, The value consists of a 4-byte timestamp (i.e. seconds since the epoch) and a 4-byte increment.

> Note: This is an internal MongoDB type used for replication and sharding. It is not intended for general date storage (MongoDB\BSON\UTCDateTime should be used instead).

## Class synopsis

final class MongoDB\BSON\Timestamp implements MongoDB\BSON\TimestampInterface, MongoDB\BSON\Type, JsonSerializable, Stringable {
/* Methods */
final public __construct(int `$increment`, int `$timestamp`)
final public getIncrement(): int
final public getTimestamp(): int
final public jsonSerialize(): mixed
final public __toString(): string
}

## Changelog

Version | Description
--- | ---
PECL mongodb 2.0.0 | This class no longer implements the Serializable interface.
PECL mongodb 1.12.0 | Implements Stringable for PHP 8.0+.
PECL mongodb 1.3.0 | Implements MongoDB\BSON\TimestampInterface.
PECL mongodb 1.2.0 | Implements Serializable and JsonSerializable.

## Table of Contents

- MongoDB\BSON\Timestamp::__construct — Construct a new Timestamp
- MongoDB\BSON\Timestamp::getIncrement — Returns the increment component of this Timestamp
- MongoDB\BSON\Timestamp::getTimestamp — Returns the timestamp component of this Timestamp
- MongoDB\BSON\Timestamp::jsonSerialize — Returns a representation that can be converted to JSON
- MongoDB\BSON\Timestamp::__toString — Returns the string representation of this Timestamp