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:
- Procedural style:
int date_timestamp_get( $object )
- Object oriented style:
int DateTime::getTimestamp( void ) int DateTimeImmutable::getTimestamp( void ) int DateTimeInterface::getTimestamp( void )
Parameters: This function accepts single parameter $object which is a mandatory. It is used to specify the DateTime object which is returned by the date_create() function. It is used in procedural style only. The object oriented style does not accept any parameter.
Return Value: This function returns the Unix timestamp representing the date.
Below programs illustrate the date_timestamp_get() function in PHP:
Program 1:
<?php // Create DateTime object $date = date_create(); // Display Unix timestamp date echo date_timestamp_get($date); ?> |
1537162804
Program 2:
<?php // Create DateTime object $date = new DateTime(); // Display Unix timestamp date echo $date->getTimestamp(); ?> |
1537162805
Related Articles:
Reference: http://php.net/manual/en/datetime.gettimestamp.php
Recommended Posts:
- How to get the function name inside a function in PHP ?
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
- PHP | fpassthru( ) Function
- PHP | ImagickDraw getTextAlignment() Function
- PHP | Ds\Sequence last() Function
- Function to escape regex patterns before applied in PHP
- PHP | array_udiff_uassoc() Function
- PHP | geoip_continent_code_by_name() Function
- PHP | GmagickPixel setcolor() function
- PHP | opendir() Function
- PHP | cal_to_jd() Function
- PHP | stream_get_transports() Function
- PHP | Ds\Deque pop() Function
- PHP | SimpleXMLElement children() Function
- PHP | array_intersect_ukey() Function
- PHP | is_numeric() Function
- PHP | Imagick adaptiveSharpenImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

