48

2011-03-04 21:00:40

I want to get current date and time in the above format. How do I do this in PHP?

4
  • 2
    Googling "php date format" brings up php.net/manual/en/function.date.php as the first hit Commented Mar 5, 2011 at 21:18
  • 4
    Overview of PHP date/time functions Commented Mar 5, 2011 at 21:18
  • From which value do you want to convert? Actual date? Stored value in some variable? Commented Mar 5, 2011 at 21:20
  • Below All three giving same answer and getting upvote. Commented May 13, 2015 at 12:47

3 Answers 3

129

date('Y-m-d H:i:s'). See the manual for more.

Sign up to request clarification or add additional context in comments.

Comments

18
date("Y-m-d H:i:s"); // This should do it.

Comments

11

I belive the answer is:

echo date('Y-m-d H:i:s');

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.