DateTime::getTimestamp

DateTimeImmutable::getTimestamp

DateTimeInterface::getTimestamp

date_timestamp_get

Gets the Unix timestamp

Beschreibung

Objektorientierter Stil

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

Prozeduraler Stil

int date_timestamp_get ( DateTimeInterface $object )

Gets the Unix timestamp.

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Returns the Unix timestamp representing the date.

Beispiele

Beispiel #1 DateTime::getTimestamp example

Objektorientierter Stil

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

Prozeduraler Stil

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

Oben gezeigte Beispiele erzeugen eine ähnliche Ausgabe wie:

1272509157

Anmerkungen

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

Siehe auch

  • DateTime::setTimestamp
  • DateTime::format