The provided results based on the timezone settings in the php.ini file. You may need to modify this setting to get date and time in the required timezone. Read this tutorial to set timezone in PHP configuration.

Using date() Function

PHP date() function converts the timestamp stored in computer memory in a human-readable format. The syntax of date() function is as: The below php script will return current date time in ‘Y-m-d H:i:s’ format.

Result:- Other useful examples:

Using DateTime() Class:

The DateTime() class functions allow you to get the date and time. You can also use functions to format the date and time in many different ways.

Result:- References: