将姓名转换成数字
有一个简单的方法来改变$month = "July"; 所以$nmonth = 7 ( 07也可以)。 我可以做一个案例的声明,但肯定已经有一个function转换? 编辑:我希望我可以接受多个答案,因为你们两个基本上给了我你需要的权力加在一起。 
 $nmonth = date('m',strtotime($month)); 
 这将给出$month的数值。 谢谢! 
是,
 $date = 'July 25 2010'; echo date('d/m/Y', strtotime($date)); 
  m将月份格式化为在那里的数字表示。 
尝试这个:
 <?php $date = date_parse('July'); var_dump($date['month']); ?> 
这里有趣的一面,凯利给出的代码运行良好,
 $nmonth = date("m", strtotime($month)); 
但是在二月份,闰年为30或31,非闰年为29,30,31,不会如预期的那样工作,它会以月份的数字返回3 。 例如:
 $nmonth = date("m", strtotime("february")); 
解决scheme是,像这样添加一个月份的月份:
 $nmonth = date("m", strtotime("february-2012")); 
我从这个评论中得到了这个在PHP手册。
 $string = "July"; echo $month_number = date("n",strtotime($string)); 
返回“7”[月号]
 使用date("m",strtotime($string)); 为输出“08” 
 对于更多的格式reffer这.. 
  http://php.net/manual/en/function.date.php 
你也可以使用这个:
 $month = $monthname = date("M", strtotime($month)); 
 $nmonth = date("m", strtotime($month)); 
创build一个假date可能是最容易的,所以你可以使用date函数。
在这里很好的参考: http : //php.net/manual/en/function.date.php
例:
 <? $month = 7; $tempDate = mktime(0, 0, 0, $month, 1, 1900); echo date("m",$tempDate); ?> 
 $monthname = date("F", strtotime($month)); 
  F表示完整的月份名称 
 也许使用strtotime()和date() ? 
 <?php $monthNum = 5; $monthName = date("F", mktime(0, 0, 0, $monthNum, 10)); echo $monthName; //output: May ?> 
使用
 date("F", mktime(0, 0, 0, ($month))); where, $month value will be 1 -> 12 
以上答案是好的。 这是另一种方法:
 function getMonthNumber($monthStr) { //eg, $month='Jan' or 'January' or 'JAN' or 'JANUARY' or 'january' or 'jan' $m = ucfirst(strtolower(trim($monthStr))); switch ($m) { case "January": case "Jan": $m = "01"; break; case "Febuary": case "Feb": $m = "02"; break; case "March": case "Mar": $m = "03"; break; case "April": case "Apr": $m = "04"; break; case "May": $m = "05"; break; case "June": case "Jun": $m = "06"; break; case "July": case "Jul": $m = "07"; break; case "August": case "Aug": $m = "08"; break; case "September": case "Sep": $m = "09"; break; case "October": case "Oct": $m = "10"; break; case "November": case "Nov": $m = "11"; break; case "December": case "Dec": $m = "12"; break; default: $m = false; break; } return $m; } 
用PHP 5.4,你可以把马修的答案变成一行:
 $date = sprintf('%d-%d-01', $year, date_parse('may')['month']); 
 $date = 'Dec 25 2099'; echo date('d/m/Y', strtotime($date)); 
 这将返回01/01/1970 ,这意味着PHP不支持所有date,它将返回正确的格式化date,直到Jan 19 2038年Jan 19 2038但Jan 20 2038 01/01/1970 Jan 20 2038返回01/01/1970 
 $dt = '2017-Jan-10'; OR $dt = '2017-January-10'; 
echo date('Ym-d',strtotime($ dt));
回声date('Y / m / d',strtotime($ dt));
我知道这似乎是一个简单的解决scheme,但为什么不使用这样的东西
 <select name="month"> <option value="01">January</option> <option value="02">February</option> <option selected value="03">March</option> </select> 
用户看到二月份,但是02被张贴到数据库