PHP | time() Function Last Updated : 05 May, 2018 Comments Improve Suggest changes Like Article Like Report The time() function is a built-in function in PHP which returns the current time measured in the number of seconds since the Unix Epoch. The number of seconds can be converted to the current date using date() function in PHP. Syntax: int time() Parameter: This function does not accepts any parameters as shown above. Return Value: This function returns the current time measured in the number of seconds since the Unix Epoch. Note: All output of programs corresponds to the date when the article was written. Below programs illustrate the time() function: Program 1: The program below prints the current time in term of seconds. php <?php // PHP program to demonstrate the use of current // time in seconds since Unix Epoch // variable to store the current time in seconds $currentTimeinSeconds = time(); // prints the current time in seconds echo $currentTimeinSeconds; ?> Output: 1525376494 Program 2: The program below prints the current time in date format. php <?php // PHP program to demonstrate the use of current // date since Unix Epoch // variable to store the current time in seconds $currentTimeinSeconds = time(); // converts the time in seconds to current date $currentDate = date('Y-m-d', $currentTimeinSeconds); // prints the current date echo ($currentDate); ?> Output: 2018-05-03 Comment More infoAdvertise with us Next Article PHP | time() Function G gopaldave Follow Improve Article Tags : Misc Web Technologies PHP PHP-date-time Practice Tags : Misc Similar Reads PHP | strptime() Function The strptime() function is an inbuilt function in PHP which is used to parse a time / date generated with strftime() function. The date and format are sent as a parameter to the strptime() function and it returns an array on success or False on failure. The array returned by the strptime() function 2 min read PHP | strftime() Function The strftime() function is an inbuilt function in PHP that formats local time or date according to locale settings i.e. it formats local time or date for location set for it of a place. Syntax: strftime( $format, $timestamp ) Parameters: This function accept two parameters as mentioned above and des 5 min read PHP | strtotime() Function The strtotime() function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp. The function accepts a string parameter in English which represents the description of date-time. For e.g., "now" refers to the current date in English date-t 2 min read PHP | sleep( ) Function The sleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds. The sleep( ) function accepts seconds as a parameter and returns TRUE on success or FALSE on failure. If the call is interrupted by a signal, sleep() funct 2 min read PHP | date_time_set() Function The date_time_set() function is an inbuilt function in PHP which is used to sets the time. This function resets the current time of the DateTime object to a different time. Syntax: Procedural style: date_time_set( $object, $hour, $minute, $second, $microseconds ) Object oriented style: DateTime::set 2 min read Like