PHP Month Number to Month Name

By gilbitron in PHP on 31/03/2009 at 03:17

Views: 2566
Tagged: php, date

Starter:

An easy way to convert a month number to a month name without a switch statement.

Main Course:

$monthName = date("F", mktime(0, 0, 0, $monthNum, 10)); 

Expand Report Code | Install Coda Clip

Please log in to vote.

Compliments to the Chef

  1. Comment by http://www.myopenad.com on 30/05/2009 at 03:07

    http://www.myopenad.com

  2. Comment by Christopher Shennan on 27/07/2009 at 07:41

    Fantastic... This was a nice quick solution to my problem. I was after the month names from November to Aprils so I tweaked this as follows:

    for($i=1;$i

  3. Comment by Christopher Shennan on 27/07/2009 at 07:42

    Fantastic... This was a nice quick solution to my problem. I was after the month names from November to Aprils so I tweaked this as follows:

    for($i=1;$i<=6;$i++) {
    echo date("F", mktime(0, 0, 0, (($i+10) % 12), 10));
    }

How was your Meal?


  • Allowed HTML: <b><strong><u><i><em><a>

  • Why ask? It helps us stop spam comments.