jacko_162 Posted April 6, 2010 Share Posted April 6, 2010 i have a date stored in mysql database but unfortunatly its not stored in date format as per phpmyadmin. its a VARCHAR and displays like: April 1, 2010 is there anyway i can query the database and pull down the $date value and instead of echoing "April 1, 2010" i can split it to echo the month?? and a seperate query to echo the day?? pretty silly of me not reading up on the date thing though and now i have a bucket load of users who i cant change the date field... Quote Link to comment https://forums.phpfreaks.com/topic/197784-pulling-information-and-split/ Share on other sites More sharing options...
budlust Posted April 6, 2010 Share Posted April 6, 2010 you might want to look at this http://php.net/manual/en/function.explode.php Quote Link to comment https://forums.phpfreaks.com/topic/197784-pulling-information-and-split/#findComment-1037923 Share on other sites More sharing options...
jacko_162 Posted April 6, 2010 Author Share Posted April 6, 2010 Very usefull i used the explode function and i managed to split $date by doing: <?php $splitdate = explode(" ", " $date "); echo $splitdate[3]; // prints "Day"; echo "<br>"; // prints space; echo $splitdate[2]; // prints "Month"; ?> only problem i get now is that it echos this: "April 6," i dont want it to echo the "," this is what i get when i echo the $date "April 6, 2010" can anyone help me a little further? Quote Link to comment https://forums.phpfreaks.com/topic/197784-pulling-information-and-split/#findComment-1038016 Share on other sites More sharing options...
jcbones Posted April 6, 2010 Share Posted April 6, 2010 Try something like this: <?php $splitdate = explode(" ",trim($date)); echo str_replace(',','',$splitdate[1]); // prints "Day"; echo "<br />"; // prints space; echo $splitdate[0]; // prints "Month"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/197784-pulling-information-and-split/#findComment-1038019 Share on other sites More sharing options...
jacko_162 Posted April 6, 2010 Author Share Posted April 6, 2010 thank you Quote Link to comment https://forums.phpfreaks.com/topic/197784-pulling-information-and-split/#findComment-1038039 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.