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 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 PHP | timezone_open() Function The timezone_open() function is an inbuilt function in PHP which is used to create a new DateTimeZone object. The timezone_open() function accepts the timezone as a parameter and returns the DateTimeZone object on success or False on failure. Syntax: timezone_open( $timezone ) Parameters: This funct 2 min read PHP | hrtime() Function The hrtime() function is an inbuilt function in PHP which returns the high-resolution time of the system. Syntax: mixed hrtime( bool $is_num_return ); Parameter: This function accepts a single parameter as mentioned above and described below: $is_num_return: It is optional parameter of Boolean type. 1 min read PHP | usleep( ) Function The usleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for specific microseconds. It is similar to the sleep() function which delays execution of the current script for a specified number of seconds, unlike the usleep() function which delays th 2 min read PHP | time_nanosleep( ) Function The time_nanosleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds and nanoseconds. The time_nanosleep() function accepts seconds and nanoseconds as parameters and returns TRUE on success or FALSE on failure. If th 2 min read PHP | time_sleep_until( ) Function The time_sleep_until() function in PHP is an inbuilt function which is used to delay execution of the current script until the specified time. The time_sleep_until( ) function accepts timestamp as a parameter and this timestamp denotes when the script should wake. The time_sleep_until( ) function re 2 min read Like