jim.davidson Posted February 18, 2010 Share Posted February 18, 2010 I have a mysql table that has mutiple date fields. I have some code that gets the date field that I'm looking for. I then store that date to a variable. $this_date = $row_getBus['feb_date']; $this_date now contains 2010-02-22 I now want to display this as February 22, 2010. I can't seem to be able to find a function that will do this. Can anyone help me? I will be greatfull for any help with this. Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 18, 2010 Share Posted February 18, 2010 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014322 Share on other sites More sharing options...
JonnoTheDev Posted February 18, 2010 Share Posted February 18, 2010 Funily enough the function is called date(). http://php.net/date print date("F d, Y", strtotime($this_date)); Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014324 Share on other sites More sharing options...
jl5501 Posted February 18, 2010 Share Posted February 18, 2010 try strftime("%B %d, %Y",strtotime($this_date)); Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014325 Share on other sites More sharing options...
jim.davidson Posted February 18, 2010 Author Share Posted February 18, 2010 I had already tried what you suggest and I do see the date. I'm missing somethig. Here's my code, (I'm a beginner so it is more then likely sloppy to all you pros) $bus_dates = array(); mysql_select_db($database_myData, $myID); $query_getBus = "SELECT * FROM meetings WHERE type = 'Business'"; $getBus = mysql_query($query_getBus, $myID) or die(mysql_error()); $row_getBus = mysql_fetch_assoc($getBus); // $totalRows_getBus = mysql_num_rows($getBus); $counter = 0; $today = date('Y-m-d'); $bus_dates[] = $row_getBus['jan_date']; $bus_dates[] = $row_getBus['feb_date']; $bus_dates[] = $row_getBus['mar_date']; $bus_dates[] = $row_getBus['apr_date']; $bus_dates[] = $row_getBus['may_date']; $bus_dates[] = $row_getBus['jun_date']; $bus_dates[] = $row_getBus['jul_date']; $bus_dates[] = $row_getBus['aug_date']; $bus_dates[] = $row_getBus['sep_date']; $bus_dates[] = $row_getBus['oct_date']; $bus_dates[] = $row_getBus['nov_date']; $bus_dates[] = $row_getBus['dec_date']; // Find the next meeting date for ($counter=0; $counter <12; $counter++) { if ($bus_dates[$counter] >= $today) { echo "<BR>$bus_dates[$counter]"; exit; } } $display_date = date("F d, Y", strtotime($bus_date)); echo $display_date; Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014333 Share on other sites More sharing options...
jl5501 Posted February 18, 2010 Share Posted February 18, 2010 you have exit in your for loop. I think you mean break; exit will stop the script Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014340 Share on other sites More sharing options...
jim.davidson Posted February 18, 2010 Author Share Posted February 18, 2010 Thank you jl5501 So I'm not going crazy. The exit comes from my days as a Clipper programmer. In that language you used exit to get out of a loop. Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014342 Share on other sites More sharing options...
JonnoTheDev Posted February 18, 2010 Share Posted February 18, 2010 What is incorrect is that the variable $bus_date has no value. It has never been initialised anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014344 Share on other sites More sharing options...
jl5501 Posted February 18, 2010 Share Posted February 18, 2010 ah ok, I never did clipper did cobol, then c and pascal before php Quote Link to comment https://forums.phpfreaks.com/topic/192516-displaying-a-date/#findComment-1014345 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.