ultrus Posted January 31, 2008 Share Posted January 31, 2008 My coffee has not set in yet, so please pardon the silly question: I'm getting dates from a database that is in the format of "YYYY-MM-DD". Is there a simple way of converting this to "Month D", or do I need to write a more lengthy function for this making use of substrings etc.? (If more lengthy, no need to post code. I can get it figured out.) Thanks much! Quote Link to comment https://forums.phpfreaks.com/topic/88755-solved-reformatting-a-date-yyyy-mm-dd-to-month-d/ Share on other sites More sharing options...
rhodesa Posted January 31, 2008 Share Posted January 31, 2008 like this? <?php $date = "2008-01-31"; $time = strtotime($date); print date('F j',$time); ?> Quote Link to comment https://forums.phpfreaks.com/topic/88755-solved-reformatting-a-date-yyyy-mm-dd-to-month-d/#findComment-454575 Share on other sites More sharing options...
ultrus Posted January 31, 2008 Author Share Posted January 31, 2008 Oh yeah!! That rocks! Thank you rhodesa. Quote Link to comment https://forums.phpfreaks.com/topic/88755-solved-reformatting-a-date-yyyy-mm-dd-to-month-d/#findComment-454576 Share on other sites More sharing options...
revraz Posted January 31, 2008 Share Posted January 31, 2008 Searching for strtotime as the subject would also point you to many solutions, and to one that was solved about 2 hours ago. Quote Link to comment https://forums.phpfreaks.com/topic/88755-solved-reformatting-a-date-yyyy-mm-dd-to-month-d/#findComment-454581 Share on other sites More sharing options...
ultrus Posted January 31, 2008 Author Share Posted January 31, 2008 rhodesa, You are correct. I just needed to be aware of strtotime before searching for it. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/88755-solved-reformatting-a-date-yyyy-mm-dd-to-month-d/#findComment-454585 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.