Guest User

Untitled

a guest
Jul 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. echo date("m", strtotime("january"));
  2.  
  3. echo date("m", strtotime("february"));
  4.  
  5. echo date("m", strtotime("February 1"));
  6.  
  7. function getMonth($month, $leadingZero = true) {
  8. $month = strtolower(trim($month)); // Normalize
  9.  
  10. $months = array('january' => '1',
  11. 'february' => '2',
  12. 'march' => '3',
  13. 'april' => '4',
  14. 'may' => '5',
  15. 'june' => '6',
  16. 'july' => '7',
  17. 'august' => '8',
  18. 'september' => '9',
  19. 'october' => '10',
  20. 'november' => '11',
  21. 'december' => '12',
  22. 'dezember' => '12', // German abrevation
  23. 'marts' => '3', // Danish abrevation for March
  24. );
  25.  
  26. if(isset($months[$month])) {
  27. return $leadingZero ? substr('0' . $months[$month], -2) : $months[$month];
  28. } else {
  29. return false;
  30. }
  31. }
Add Comment
Please, Sign In to add comment