Jump to content

Archived

This topic is now archived and is closed to further replies.

jmcall10

Simple date php mysql question

Recommended Posts

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

Share this post


Link to post
Share on other sites
Try:

[code]<?php

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

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

echo $newdate;

?>[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.