PHP | date_timestamp_get() Function
Last Updated :
17 Sep, 2018
Improve
The date_timestamp_get() function is an inbuilt function in PHP which is used to gets the Unix timestamp. This function returns the Unix timestamp representing the date.
Syntax:
php
php
- Procedural style:
int date_timestamp_get( $object )
- Object oriented style:
int DateTime::getTimestamp( void ) int DateTimeImmutable::getTimestamp( void ) int DateTimeInterface::getTimestamp( void )
<?php
// Create DateTime object
$date = date_create();
// Display Unix timestamp date
echo date_timestamp_get($date);
?>
Output:
Program 2:
1537162804
<?php
// Create DateTime object
$date = new DateTime();
// Display Unix timestamp date
echo $date->getTimestamp();
?>
Output:
Related Articles:
Reference: http://php.net/manual/en/datetime.gettimestamp.php
1537162805