47

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?

Warren Dew
  • 8,562
  • 3
  • 29
  • 43
codereviewanskquestions
  • 12,620
  • 25
  • 97
  • 162

3 Answers3

126

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

Anomie
  • 89,707
  • 13
  • 124
  • 144
18
date("Y-m-d H:i:s"); // This should do it.
zardilior
  • 2,556
  • 23
  • 29
KJYe.Name
  • 16,531
  • 5
  • 47
  • 62
11

I belive the answer is:

echo date('Y-m-d H:i:s');
Patrick Beardmore
  • 1,040
  • 1
  • 11
  • 35