-3

There is a string posted from a web page form : Jul 21 2015. It represents a date but needs to be formatted. How to format it to be 2015-07-21 ?

pheromix
  • 18,213
  • 29
  • 88
  • 158
  • 2
    possible duplicate of [Convert one date format into another in PHP](http://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Sougata Bose Jul 21 '15 at 08:46

1 Answers1

1

strtotime:

$string = "Jul 21 2015";
$time = date("Y-m-j", strtotime($string));
Ben
  • 8,894
  • 7
  • 44
  • 80