Which PHP function is used to return the current time?

Prepare for the Zend Certified PHP Engineer Exam with our comprehensive test, featuring flashcards and multiple choice questions. Each question comes with detailed hints and explanations. Ensure you're ready for your exam!

The function that returns the current time in PHP is the time() function. This function retrieves the current Unix timestamp, which is the number of seconds that have elapsed since January 1, 1970, at 00:00:00 GMT, excluding leap seconds. It serves as a standard way to represent time and is often used in programming for date and time manipulations.

By using time(), you can perform various time-related calculations, such as determining the time elapsed, scheduling tasks, or formatting the timestamp into human-readable formats using other date/time functions like date().

The other functions listed do not exist in PHP: current_time() and get_time() are not predefined PHP functions, while now() is not recognized as a core function for retrieving time either. Thus, time() is the appropriate and correct choice for obtaining the current time in PHP.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy