Search code examples
phpdate-conversion

PHP, convert many different date formats into day-month-year


Possible Duplicate:
how to convert php date formats to GMT and vice versa?

In PHP, I have a string date like this:

May 21, 2012 07:23:15 GMT

or this

21 May 2012 07:23:15 GMT

I need to convert both the strings into something like this: 21-05-2012. (day-month-year)

Can PHP correctly parse both these strings into a day-month-year format?


Solution

  • Try This -

     $your_string = "21 May 2012 07:23:15 GMT";
     $dd = date("d-m-Y", strtotime($your_string));
     echo $dd;