jmcall10 Posted June 13, 2006 Share Posted June 13, 2006 I have this variable $line["date"]taken from a mysql database so it displays 2006-06-13however I want it to display as 13-06-2003how do I do itThanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11922-simple-date-php-mysql-question/ Share on other sites More sharing options...
Caesar Posted June 13, 2006 Share Posted June 13, 2006 Try:[code]<?php$date = strtotime(2006-06-13); // <-- Or replace the date with your variable$newdate = date("d-m-Y",$date);echo $newdate;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11922-simple-date-php-mysql-question/#findComment-45245 Share on other sites More sharing options...
jmcall10 Posted June 13, 2006 Author Share Posted June 13, 2006 Hmm another problem tho :)I have this variable$thisTime = $line[time];displays as 20:00:00 (for 8pm)I just want it to display 20:00 ( so basically without the seconds)How is this doneThanks in advancejmcall10 Quote Link to comment https://forums.phpfreaks.com/topic/11922-simple-date-php-mysql-question/#findComment-45261 Share on other sites More sharing options...
Caesar Posted June 14, 2006 Share Posted June 14, 2006 I suppose you can just remove the colon and tailing zeros...but for the sake of giving you a quick solution, here is a way which should also work:[code]$testtime = strtotime($thisTime);$newtime = date("G:i", $testtime);[/code]If [!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]$thisTime[!--colorc--][/span][!--/colorc--] = '20:00:00'.....then the output of [!--coloro:#3333FF--][span style=\"color:#3333FF\"][!--/coloro--]$newtime[!--colorc--][/span][!--/colorc--] will equal '20:00'. Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/11922-simple-date-php-mysql-question/#findComment-45297 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.