getTimestamp ($unixtimestamp);
date_timestamp_set ($date_obj,$unixtimestamp);
Gets the Unix timestamp of the date.
| Parameter | DESCRIPTION |
|---|---|
| $date_obj | Required : Input date object to be assigned new value. |
| $unixtimestamp | Required: Integer , Timestamp of new date and time |
$date = new DateTime(); // current time object
echo "Timestamp: ".$date->getTimestamp()."<br>"; // getting Timestamp
echo $date->format('U = Y-m-d H:i:s');
$date = date_create(); // current time object
echo "Timestamp: ".date_timestamp_get($date)."<br>"; // getting Timestamp
echo date_format($date, 'U = Y-m-d H:i:s');
$date = new DateTime('2016-08-25 22:15:40');
echo "Timestamp: ".$date->getTimestamp();// Output is Timestamp: 1472143540
$date = date_create('2019-12-28 22:15:40');
echo "Timestamp: ".date_timestamp_get($date); // Output is Timestamp: 1577551540
| Function | Description |
|---|---|
| mktime() | getting time stamp of input date and time |
| strtotime() | Text string of data to timestamp |
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.