-1

I have date in format 2011-01-28 06:34:33 i.e. date("Y-m-d H:i:s"). I want to convert it into 28th January 2011.

How can I change it?

ann
  • 576
  • 1
  • 10
  • 19
Pradip
  • 1,317
  • 4
  • 21
  • 36
  • 1
    -1 for not taking the time to look at the [manual for `date`](http://de2.php.net/manual/en/function.date.php) and for not [searching StackOverflow first](http://stackoverflow.com/search?q=convert+date+php). How to convert and format dates has been asked and answered countless times before. Please do not ignore [Ask Advice](http://stackoverflow.com/questions/ask-advice) – Gordon Dec 28 '10 at 08:11
  • possible duplicate of [PHP convert one date into another date format](http://stackoverflow.com/questions/2167916/php-convert-one-date-into-another-date-format) – Gordon Dec 28 '10 at 08:12

3 Answers3

2

Supply the date function with your format, which can be found here. Pass the timestamp of your original date as the second parameter to date. You can obtain the timestamp by using strtotime.

date("dS F Y", strtotime("2011-01-28 06:34:33"));
alexn
  • 57,867
  • 14
  • 111
  • 145
0

Use

$dateStr = date("jS F Y", time());

The day value is without leading zero.

0

Try this echo date('jS F Y h:i:s A');

rajmohan
  • 1,618
  • 1
  • 15
  • 36