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.
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.
Program 2: The program below prints the current time in date format.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.