The time function is used to return the current time in seconds since the unix epoch, this is also known as unix time; the unix epoch is defined as January 1 1970 00:00:00 GMT.
Right now there has approximately passed x seconds since the unix epoch, and the current date in a readable Y-m-d H:i:s format is: x.
The format of the date can be adjusted as needed, there are also different options that you can use depending your preferred date/time formatting.
You can show a human readable version of the number returned by time by combining it with the date function:
$tomorrow = time() + 86400; // 86.400 is equal to ~1 day in seconds echo 'Tomorrow: '. date('Y-m-d H:i:s', $tomorrow) ."\n";
Tomorrow: 2021-02-15 12:01:11
To get the current date, simply call the date function directly:
date_default_timezone_set("UTC"); echo date('Y-m-d H:i:s'); // 2021-02-14 12:01:11
The time function always returns a timestamp that is independent of time zone (UTC), so remember to define the time zone using date_default_timezone_set when using the date function.
The time function returns an integer and does not accept any parameters.
The following table shows how many seconds there is over different time spans:
Note that these values are not precise due to leap seconds, and also because some months have 30 days while others only have 26 days. If precision is important, you should instead use the date function.