将日期转换为2016年8月22日到2016年8月22日? [重复]

This question already has an answer here:

I have this date format: August 22, 2016

I want to convert to 08/22/2016

str_replace is the solution? eg: str_replace("August","08/",$var); but it should have at least 12 str_replaces...

any ideas for a simple way?

</div>

Refer to DateTime::format

Specify your desired date format 'm/d/Y' after creating the DateTime object.

Try this:

$date = new DateTime('August 22, 2016');
echo $date->format('m/d/Y');  // 08/22/2016

try this,

$originalDate = "August 22, 2016";
$newDate = date("m/d/Y", strtotime($originalDate));
echo $newDate;

OUTPUT

08/22/2016

DEMO

just like php date function convert to in strtotime,

Example:

$date = "August 22, 2016";
$date2 = date("m/d/Y", strtotime($date));
echo $date2;

ANS : 08/22/2016

Note: if you change date format so change in date function so u like