Forum Moderators: coopster

Message Too Old, No Replies

TimeStamp format

         

someguyinaussie

3:34 pm on Dec 19, 2003 (gmt 0)

10+ Year Member



Hey guys,

thanks for taking a look firstly,


<?php
db connections etc
$query = "SELECT * FROM mortgage";
$result = mysql_query($query);
?>

HTML CODE for tables etc

<?php
while($row = mysql_fetch_assoc($result))
{
?>

then for the results like -

<?php "DATE_FORMAT(TimeDate,'%d-%m-%Y / %H:%i')"?><?php echo $row['TimeDate'];?>

This displays the date "20031219114515" but doesnt format it to what I would like

could you tell me where Im going wrong, thanks

bcolflesh

3:39 pm on Dec 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put the Date_Format in your SELECT statement, ie:

SELECT *, DATE_FORMAT(TimeDate,'%d-%m-%Y / %H:%i') AS display_date

someguyinaussie

3:48 pm on Dec 19, 2003 (gmt 0)

10+ Year Member



Ok thanks for that but how do I put it in with the select already there?

$query = "SELECT * FROM mortgage";

Where do I put it?

thanks!

bcolflesh

4:10 pm on Dec 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$query = "SELECT *, DATE_FORMAT(TimeDate,'%d-%m-%Y / %H:%i') AS display_date FROM mortgage";

Remember to echo display_date to get the formatting.

someguyinaussie

4:58 pm on Dec 19, 2003 (gmt 0)

10+ Year Member



Thanks so much, I know for the future now

Hmm...
having a slight problem displaying it

Im using


<?php echo $display_date?>

I've tried

echo "$display_date"

etc

but still is just blank!

jatar_k

5:10 pm on Dec 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



based on this bit

while($row = mysql_fetch_assoc($result))

you would need to do

echo $row['display_date'];

bcolflesh

5:14 pm on Dec 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks jatar_k - came back too late!

someguyinaussie

5:17 pm on Dec 19, 2003 (gmt 0)

10+ Year Member



What can I say, thank you so much guys, been such a help...I value this immensely

thank you!