开发者

How to convert 02 to FEB

How to convert 02 to FEB, where is this process come from native function of php. like date('Y') then we will get this year.

examp开发者_开发知识库le like this

<?php
$var = 02;
$var = convertToMonthName($var);
// Output var will be 'FEB'
?>

Thanks in advance...


$m = strftime("%b",mktime(0,0,0,$month));


<? php
$var = 02;
$var = convertToMonthName($var);

function convertToMonthName($n)
      {
      $timestamp = mktime(0, 0, 0, $n, 1, 2011);
      return date("M", $timestamp);
      }
?>

Its a bit of a hack, but it works. It creates a time stamp for the first of that month in an arbitrary year. Then it pulls the month from it using the php date function


You could have an array of months like this:

<?php
$months = array(
    1 => 'Jan',
    2 => 'Feb'
);

echo $months[02];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜