Home  >  Article  >  Backend Development  >  Example of php code that returns month name based on month number

Example of php code that returns month name based on month number

WBOY
WBOYOriginal
2016-07-25 08:58:261606browse
This article introduces a piece of code that uses PHP to return the name of the month based on the month number. Friends in need can refer to it.

The following code implements this function: For example, the number 01 returns January, the number 02 returns February, and so on.

The code is as follows:

<?php
/**
* 根据月份数字返回月份名称
* edit bbs.it-home.org
* date 2013/6/21
*/
function Month($NumMonth) { 
   switch($NumMonth) {
      Case "01":
      return "January";
      break;
 
      Case "02":
      return "February";
      break;
 
      Case "03":
      return "March";
      break;
 
      Case "04":
      return "April";
      break;
 
      Case "05":
      return "May";
      break;
 
      Case "06":
      return "June";
      break;
 
      Case "07":
      return "July";
      break;
 
      Case "08":
      return "August";
      break;
 
      Case "09":
      return "September";
      break;
 
      Case "10":
      return "October";
      break;
 
      Case "11":
      return "November";
      break;
 
      Case "12":
      return "December";
      break;
    } 
}
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn