dreamwest Posted January 7, 2010 Share Posted January 7, 2010 Im trying to get a number to represent a date name date('F'); // january date('n'); //january = 1 So 01 = January 02 = Feburary etc... $mth = 02; $mth_name= ; //convert numeric to month name echo $mh_name; // Feburary Quote Link to comment https://forums.phpfreaks.com/topic/187526-convert-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 7, 2010 Share Posted January 7, 2010 You would use a simple look-up array - <?php // note: leading zero's make numbers octal, so to avoid problems with 08 and 09, two-character strings are used $mth_name = array('01' => 'January', '02' => 'February'); // add the rest of the months $mth = '02'; echo $mth_name[$mth]; ?> Quote Link to comment https://forums.phpfreaks.com/topic/187526-convert-date/#findComment-990119 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.