DateTime::getTimestamp

DateTimeImmutable::getTimestamp

DateTimeInterface::getTimestamp

date_timestamp_get

(PHP 5 >= 5.3.0, PHP 7)

DateTime::getTimestamp -- DateTimeImmutable::getTimestamp -- DateTimeInterface::getTimestamp -- date_timestamp_getGets the Unix timestamp

Descrierea

Stil obiect-orientat

public DateTime::getTimestamp ( ) : int
public DateTimeImmutable::getTimestamp ( ) : int
public DateTimeInterface::getTimestamp ( ) : int

Stil procedural

Gets the Unix timestamp.

Parametri

Această funcție nu are parametri.

Valorile întoarse

Returns the Unix timestamp representing the date.

Istoricul schimbărilor

Versiune Descriere
8.0.0 These functions no longer return false on failure.

Exemple

Example #1 DateTime::getTimestamp() example

Stil obiect-orientat

<?php
$date 
= new DateTime();
echo 
$date->getTimestamp();
?>

Stil procedural

<?php
$date 
date_create();
echo 
date_timestamp_get($date);
?>

Exemplele de mai sus vor afișa ceva similar cu:

1272509157

Note

Using U as the parameter to DateTime::format() is an alternative when using PHP 5.2.

A se vedea și