convert month from name to number
An interesting look here, the code given by kelly works well,
$nmonth = date("m", strtotime($month));
but for the month of february, it won't work as expected when the current day is 30 or 31 on leap year and 29,30,31 on non-leap year.It will return 3 as month number. Ex:
$nmonth = date("m", strtotime("february"));
The solution is, add the year with the month like this:
$nmonth = date("m", strtotime("february-2012"));
I got this from this comment in php manual.
Yes,
$date = 'July 25 2010';
echo date('d/m/Y', strtotime($date));
The m
formats the month to its numerical representation there.
Try this:
<?php
$date = date_parse('July');
var_dump($date['month']);
?>