Open In App

PHP | DateTimeImmutable setTimestamp() Function

Last Updated : 10 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The DateTimeImmutable::setTimestamp() function is an inbuilt function in PHP which is used to set the date and time based on an Unix timestamp. Syntax:
DateTimeImmutable DateTimeImmutable::setTimestamp( int $unixtimestamp )
Parameters: This function accepts single parameter $unixtimestamp which is used to set the Unix timestamp representing the date. Return Values: This function returns the DateTimeImmutable object. Below programs illustrate the DateTimeImmutable::setTimestamp() function in PHP: Program 1:
Output:
1570187170 = 04-10-2019 11:06:10
Program 2:
Output:
1570187171 = 04-10-2019 11:06:11
Reference: https://www.php.net/manual/en/datetimeimmutable.settimestamp.php

Next Article

Similar Reads