xiao Posted January 12, 2008 Share Posted January 12, 2008 What I need: - Get the day and month out of a mysql 'date' cell - Transform the month to text - Take the 1st 3 characters from the month name What I have: $date = explode("-", $info['submitdatum']); $day=$date[2]; $month=$date[1]; I'm stuck now Quote Link to comment Share on other sites More sharing options...
phpSensei Posted January 12, 2008 Share Posted January 12, 2008 <?php $date = explode("-", $info['submitdatum']); $day=$date[2]; $month=$date[1]; $month = substr($month,0,3); ?> RESULTS Oct Also an easier way to do this is by transforming it when you put it in the DB. For example <?php $current = time(); $current = date("Y-m-d",$current); // Do query $month = explode("-",$current); $month = $month[1]; echo $month; // JAN, SEP, ...etc ?> http://ca3.php.net/substr http://ca3.php.net/manual/en/function.date.php Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 12, 2008 Share Posted January 12, 2008 Just do it directly in your mysql SELECT query - SELECT DATE_FORMAT(submitdatum,'%e %b') FROM your_table WHERE your_where_conditions... This returns the day of the month, numeric (0..31) and the abbreviated month name (Jan..Dec) Done! Quote Link to comment 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.