多个IF语句不起作用?

Chr*_*ill 1 php if-statement

我正在研究一些代码,它将一个月变为其数字.

$postdate = "09:24:33 Mar 07, 2014 PST";

//SPLIT UP DATE
$hour = substr("$postdate", 0, -23);
$min = substr("$postdate", 3, -20);
$sec = substr("$postdate", 6, -17);
$month = substr("$postdate", 9, -13);
$day = substr("$postdate", 13, -10);
$year = substr("$postdate", 17, -4); 

//SET MONTH TO NUMBER
if($month = "Jan") {$month = 01;}
if($month = "Feb") {$month = 02;}
if($month = "Mar") {$month = 03;} 
if($month = "Apr") {$month = 04;} 
if($month = "May") {$month = 05;} 
if($month = "Jun") {$month = 06;}
if($month = "Jul") {$month = 07;} 
if($month = "Aug") {$month = 08;} 
if($month = "Sep") {$month = 09;}
if($month = "Oct") {$month = 10;} 
if($month = "Nov") {$month = 11;} 
if($month = "Dec") {$month = 12;} 

//Display Month
month: <?php echo $month ?>
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?如果我只使用一个语句,它工作正常.我也会在这里走很远的路吗?是否已经有一个功能将一个月变为其数量?

谢谢.

Joh*_*nde 5

方式比它需要的更复杂:

echo date('m', strtotime("09:24:33 Mar 07, 2014 PST"));
// Output: 03
Run Code Online (Sandbox Code Playgroud)

演示