liammc87 Posted May 17, 2007 Share Posted May 17, 2007 I was just wondering how this is done? My months are stored from 01-12; how do I print their name? (January - December) Quote Link to comment https://forums.phpfreaks.com/topic/51818-month-number-to-name/ Share on other sites More sharing options...
taith Posted May 17, 2007 Share Posted May 17, 2007 <?php function switch_month($m){ while($m{0}=="0") $m=substr($m,1); $m=strtolower($m); switch($m){ case "1": return "january"; break; case "2": return "february"; break; case "3": return "march"; break; case "4": return "april"; break; case "5": return "may"; break; case "6": return "june"; break; case "7": return "july"; break; case "8": return "august"; break; case "9": return "september"; break; case "10": return "october"; break; case "11": return "november"; break; case "12": return "december"; break; case "january": return "1"; break; case "february": return "2"; break; case "march": return "3"; break; case "april": return "4"; break; case "may": return "5"; break; case "june": return "6"; break; case "july": return "7"; break; case "august": return "8"; break; case "september": return "9"; break; case "october": return "10"; break; case "november": return "11"; break; case "december": return "12"; break; } } echo switch_month(rand(1,12)); ?> Quote Link to comment https://forums.phpfreaks.com/topic/51818-month-number-to-name/#findComment-255314 Share on other sites More sharing options...
jitesh Posted May 17, 2007 Share Posted May 17, 2007 SELECT MONTHNAME('1998-02-05'); Quote Link to comment https://forums.phpfreaks.com/topic/51818-month-number-to-name/#findComment-255317 Share on other sites More sharing options...
jitesh Posted May 17, 2007 Share Posted May 17, 2007 SELECT DATE_FORMAT('2007-02-02',"%d %M %Y"); Quote Link to comment https://forums.phpfreaks.com/topic/51818-month-number-to-name/#findComment-255325 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.