Jump to content


Photo

Simple date php mysql question


  • Please log in to reply
3 replies to this topic

#1 jmcall10

jmcall10
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 13 June 2006 - 09:38 PM

I have this variable

$line["date"]

taken from a mysql database so it displays 2006-06-13

however I want it to display as 13-06-2003

how do I do it

Thanks in advance

jmcall10

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 13 June 2006 - 09:52 PM

Try:

<?php

$date = strtotime(2006-06-13);  // <-- Or replace the date with your variable

$newdate = date("d-m-Y",$date);

echo $newdate;

?>

PHP Ninja

#3 jmcall10

jmcall10
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 13 June 2006 - 10:22 PM

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 done

Thanks in advance

jmcall10

#4 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 14 June 2006 - 12:19 AM

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:

$testtime = strtotime($thisTime);
$newtime = date("G:i", $testtime);

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.
PHP Ninja




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users