PHP date_timestamp_set() Function
In this chapter you will learn:
- Definition for PHP date_timestamp_set() Function
- Syntax for PHP date_timestamp_set() Function
- Parameter for PHP date_timestamp_set() Function
- Return for PHP date_timestamp_set() Function
- Example - Set the date and time based on a Unix timestamp
Definition
The date_timestamp_set() function sets the date and time based on a Unix timestamp.
Syntax
PHP date_timestamp_set() Function has the following syntax.
date_timestamp_set(object,unixtimestamp);
Parameter
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create(). |
unixtimestamp | Required. | Unix timestamp representing the date |
Return
PHP date_timestamp_set() Function returns the DateTime object. FALSE on failure.
Example
Set the date and time based on a Unix timestamp:
<?php/*from ja v a 2 s .c om*/
$date=date_create();
date_timestamp_set($date,1234500000);
echo date_format($date,"U = Y-m-d H:i:s");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date_timezone_get() Function
- Syntax for PHP date_timezone_get() Function
- Parameter for PHP date_timezone_get() Function
- Return value for PHP date_timezone_get() Function
- Example - Return the timezone of the given DateTime object
Home » PHP Tutorial » PHP Date Functions