Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo date("m", strtotime("january"));
- echo date("m", strtotime("february"));
- echo date("m", strtotime("February 1"));
- function getMonth($month, $leadingZero = true) {
- $month = strtolower(trim($month)); // Normalize
- $months = array('january' => '1',
- 'february' => '2',
- 'march' => '3',
- 'april' => '4',
- 'may' => '5',
- 'june' => '6',
- 'july' => '7',
- 'august' => '8',
- 'september' => '9',
- 'october' => '10',
- 'november' => '11',
- 'december' => '12',
- 'dezember' => '12', // German abrevation
- 'marts' => '3', // Danish abrevation for March
- );
- if(isset($months[$month])) {
- return $leadingZero ? substr('0' . $months[$month], -2) : $months[$month];
- } else {
- return false;
- }
- }
Add Comment
Please, Sign In to add comment