PHP 8.4.22 Released!

DateTimeImmutable::createFromTimestamp

(PHP 8 >= 8.4.0)

DateTimeImmutable::createFromTimestampCreates an instance from a Unix timestamp

Descrição

public static function DateTimeImmutable::createFromTimestamp(int|float $timestamp): static

Creates an instance from a Unix timestamp.

Parâmetros

timestamp
Unix timestamp representing the date. A float value is also accepted which allows for microsecond precision.

Valor Retornado

Returns a new DateTimeImmutable instance.

Erros/Exceções

If the timestamp is outside the range [PHP_INT_MIN, PHP_INT_MAX], a DateRangeError is thrown.

Exemplos

Exemplo #1 DateTimeImmutable::createFromTimestamp() example

<?php
$date
= DateTimeImmutable::createFromTimestamp(123.456789);
echo
$date->format('Y-m-d H:i:s.u');
?>

O exemplo acima produzirá:

1970-01-01 00:02:03.456789
adicionar nota

Notas de Usuários

Não há notas de usuários para esta página.
To Top