son Posted December 6, 2008 Share Posted December 6, 2008 I have a date column in db and display relevant field on page as:$row['date']How can I format that it displays as DD/MM/YYYY instead of YYYY-MM-DD?Son Link to comment Share on other sites More sharing options...
zppblood Posted December 6, 2008 Share Posted December 6, 2008 <?php $date=explode('-', $row['date']); echo $date[2].'/'.$date[1].'/'.$date[0];?> Link to comment Share on other sites More sharing options...
son Posted December 6, 2008 Author Share Posted December 6, 2008 <?php $date=explode('-', $row['date']); echo $date[2].'/'.$date[1].'/'.$date[0];?> I tested it, but give me only the two '/'. Does this work for you?Thanks,Son Link to comment Share on other sites More sharing options...
jeffman Posted December 6, 2008 Share Posted December 6, 2008 For this to work, the items in $row['date'] must be separated by the - character. That's what you posted, so that's the way mma_fighter123 wrote the routine. If it's really a different character, you'll have to put that in the first argument of the explode function.There are several hypen/dash characters. Maybe you just need to figure out which one? Link to comment Share on other sites More sharing options...
son Posted December 6, 2008 Author Share Posted December 6, 2008 For this to work, the items in $row['date'] must be separated by the - character. That's what you posted, so that's the way mma_fighter123 wrote the routine. If it's really a different character, you'll have to put that in the first argument of the explode function.There are several hypen/dash characters. Maybe you just need to figure out which one?Tried it with copying the character from db column (2010-10-08 for example is one date entered, I copied '-'). Still the same result. It shows '/' but nothing in between... Doing a var_dump I see that date is actually NULL (so there is the actual problem). How would I be able to get $row['date']? I use a while loop to display all relevant rows (while ($row = mysqli_fetch_array ($reportResult, MYSQLI_ASSOC)) {...)Son Link to comment Share on other sites More sharing options...
jeffman Posted December 6, 2008 Share Posted December 6, 2008 Well, I hope you didn't use this: {...) :)Maybe something's up with your query string. Show that. Link to comment Share on other sites More sharing options...
son Posted December 8, 2008 Author Share Posted December 8, 2008 Got it working now. Sometimes, |-). And this quite bad...Thanks,Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.