How do you retrieve the current date and time in PHP?

In: PHP
[Edit]

Answer

By calling time() you can get the current system time as a UNIX timestamp (that is, measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)).

The usual time zone and minute length complications apply.

If you need to, you can format this into a string of text (will be understandable for humans using the Gregorian solar calendar) by calling date(...) with some useful parameters. For example:

date("r", time()) will return a string in RFC2822 format, as used by E-Mail, denoting the current system time.

date("c", time()) will return a string in ISO8601 format, as used by most database management systems for date display and input, denoting the current system time.


There are all kinds of extra formats, see <http://de3.php.net/manual/en/function.time.php>

Improve Answer Discuss the question "How do you retrieve the current date and time in PHP?" Watch Question

First answer by ID3572582944. Last edit by ID3572582944. Question popularity: 15 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Programming > PHP > How do you retrieve the current date and time in PHP?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
What is current time in panama?  What is the current date time group in Manila?  Write a program to display system current date and current time?  97 Write a program to display system current date and current time?