-   Programming (
-   -   transform month number to month name in php (

ALInux 11-09-2005 10:26 AM

transform month number to month name in php
Hi lets say Ive got a number 2 and I want to transform it into Feb but I do not want to create an array with 12 values ....I want a function that does just that .......

deiussum 11-09-2005 10:45 AM

Check out the format strings available with the date function. You can't use it directly to translate 2 to Feb, but you could probably write your own function that pieces it together into a timestamp with mktime and then use that timestamp to format the date with a short textual representation of the month.

Something like so (untested):

function GetMonthString($n)
    $timestamp = mktime(0, 0, 0, $n, 1, 2005);
    return date("M", $timestamp);

All times are GMT -5. The time now is 04:59 AM.