PHP has multiple functions to get and format date and time. Some of the most used are:
date() - formats a timestamp to a more readable date and time
time() - Return current Unix timestamp (the number of seconds since January 1 1970)
microtime() Return current Unix timestamp with microseconds
getdate() - Returns an associative array containing the date/time information
These functions allow you to get the date and time from the server where your PHP scripts are running, they dependent on the locale settings of your server.
The PHP date() function is used to format a timestamp date/time. Syntax:
format - A string format of the outputted date. Ex: "D, d M Y H:i:s" => "Mon, 15 Aug 2012 15:42:01 +0000"
timestamp - An integer Unix timestamp. It's optional. If not added, defaults to the current local time. The Unix timestamp contains the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified.
This function returns a formatted date string, or False on error.
By default, the date() function use the local server timezone, to set another default timezone, use the date_default_timezone_set('timezone_identifier'), prior to calling any of the date and time functions. The "timezone_identifier" is a string with the timezone identifier (i.g 'America/New_York' or 'Europe/Lisbon').