nashsaint Posted May 4, 2008 Share Posted May 4, 2008 Hi, I want to extract Month from SQL datetime field and convert the Number to String equivalent. I have tried Month(fieldname), which extracts the number of the month. Now I want to convert the number to String (i.e. 5=May). but I am stuck. Any help would be great. Thanks. Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/ Share on other sites More sharing options...
DarkWater Posted May 4, 2008 Share Posted May 4, 2008 SELECT MONTHNAME(fieldname) FROM table; Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532716 Share on other sites More sharing options...
papaface Posted May 4, 2008 Share Posted May 4, 2008 or in PHP <?php $month = "1"; echo date("F",mktime(0, 0, 0, $month, 1, 2008));//shows month in string form "January" ?> Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532718 Share on other sites More sharing options...
DarkWater Posted May 4, 2008 Share Posted May 4, 2008 He's selecting it from a MySQL database. Just use my method. =/ Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532721 Share on other sites More sharing options...
papaface Posted May 4, 2008 Share Posted May 4, 2008 He's selecting it from a MySQL database. Just use my method. =/ Yes I know he is. I am showing him a way to do it in PHP..... Believe it or not I can read. Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532724 Share on other sites More sharing options...
DarkWater Posted May 4, 2008 Share Posted May 4, 2008 Okay.....but he didn't ask for a way to do it in PHP....if he did, I wouldn't have said anything about your post. O_O Calm down. Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532729 Share on other sites More sharing options...
nashsaint Posted May 4, 2008 Author Share Posted May 4, 2008 Thanks a lot guys. I used DarkWater's method, just as I wanted, and it works fine. Thank you very much. Link to comment https://forums.phpfreaks.com/topic/104068-solved-month-number-to-string/#findComment-532820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.