Smudly Posted September 29, 2010 Share Posted September 29, 2010 Hey, I am grabbing a date from a row in my table which is currently formatted as: date("Y-m-d") 2010-09-29 So in my code I have something like this: $row['date']; How do I use this to rearrange the date to look like: 09-29-2010 I looked at the formatting tutorials, but they explain how to format it for the date you are currently setting into a variable. Quote Link to comment Share on other sites More sharing options...
the182guy Posted September 29, 2010 Share Posted September 29, 2010 You do it in your MySQL SELECT query like SELECT DATE_FORMAT(`date`, '%m/%d/%Y') AS date_fmt Quote Link to comment Share on other sites More sharing options...
Smudly Posted September 29, 2010 Author Share Posted September 29, 2010 Alright, that may contradict with the queries I already have going. How would I modify this? $result = mysql_query("SELECT * FROM sheets WHERE artist REGEXP '^[$mysortletter]' && active='yes' && title!='' ORDER BY artist $sortcount"); Quote Link to comment Share on other sites More sharing options...
the182guy Posted September 29, 2010 Share Posted September 29, 2010 Try $result = mysql_query("SELECT sheets.*, DATE_FORMAT(`date`, '%m/%d/%Y') AS date_fmt FROM sheets WHERE artist REGEXP '^[$mysortletter]' && active='yes' && title!='' ORDER BY artist $sortcount"); The formatted date will be in the field date_fmt 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.