PHP 8.1.28 Released!

MongoDB\BSON\ObjectId::getTimestamp

(mongodb >=1.2.0)

MongoDB\BSON\ObjectId::getTimestampReturns the timestamp component of this ObjectId

Descripción

final public MongoDB\BSON\ObjectId::getTimestamp(): int

The timestamp component of an ObjectId is its most significant 32 bits, which denotes the number of seconds since the Unix epoch. This value is read as an unsigned 32-bit integer with big-endian byte order.

Nota: Debido a que le tipo de entero de PHP es con signo, algunos valores devueltos por este método podrían aparecer como enteros negativos en plataformas de 32 bits. El formateador "%u" de sprintf() se puede usar para obtener una representación de string del valor decimal sin signo.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Returns the timestamp component of this ObjectId.

Errores/Excepciones

Ejemplos

Ejemplo #1 MongoDB\BSON\ObjectId::getTimestamp() example

<?php

var_dump
((new MongoDB\BSON\ObjectId())->getTimestamp());

var_dump((new MongoDB\BSON\ObjectId('0000002a0000000000000000'))->getTimestamp());

?>

El resultado del ejemplo sería algo similar a:

integer(1484854719)
integer(42)
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top