rilana Posted October 27, 2008 Share Posted October 27, 2008 Hi guyes I am having troubles formatting my dates the right way. I know it's supposed to be easy, but I dont get what I do wrong. <?php $link = mysql_connect("localhost","_","_"); mysql_select_db("_"); $query = 'SELECT * FROM news'; $results = mysql_query($query); $line = 2; echo "<?xml version=\"1.0\"?>\n"; echo "<news>\n"; echo "<n>" . $line. "</n>\n"; while($line = mysql_fetch_assoc($results)) { $datum = date("d-m-Y"); echo "<event>\n"; echo "<title>" . $line["titel"] . "</title>\n"; echo "<date>" . $line["datum"] . "</date>\n"; echo "<text>" . $line["text"] . "</text>\n"; echo "<url>" . $line["link"] . "</url>\n"; echo "</event>\n"; } echo "</news>\n"; mysql_close($link); ?> Can anyone tell me please what I'am doing wrong? Thanks a lot, Rilana Quote Link to comment Share on other sites More sharing options...
IndyTechNerd Posted October 27, 2008 Share Posted October 27, 2008 Hi guyes I am having troubles formatting my dates the right way. I know it's supposed to be easy, but I dont get what I do wrong. <?php $link = mysql_connect("localhost","_","_"); mysql_select_db("_"); $query = 'SELECT * FROM news'; $results = mysql_query($query); $line = 2; echo "<?xml version=\"1.0\"?>\n"; echo "<news>\n"; echo "<n>" . $line. "</n>\n"; while($line = mysql_fetch_assoc($results)) { $datum = date("d-m-Y"); echo "<event>\n"; echo "<title>" . $line["titel"] . "</title>\n"; echo "<date>" . $line["datum"] . "</date>\n"; echo "<text>" . $line["text"] . "</text>\n"; echo "<url>" . $line["link"] . "</url>\n"; echo "</event>\n"; } echo "</news>\n"; mysql_close($link); ?> Can anyone tell me please what I'am doing wrong? Thanks a lot, Rilana what does your output look like? $datum = date("d-m-Y") would be 27-10-2008 but you've never formatted $line['datum'] (assuming that's a date also). Quote Link to comment Share on other sites More sharing options...
rilana Posted October 27, 2008 Author Share Posted October 27, 2008 hy, my output looks like 2008-10-10 unstead of 10-10-2008. I thaught I was formating the echo "<date>" . $line["datum"] . "</date>\n"; by saying that datum is supposed to be formated lke that... $datum = date("d-m-Y"); What do I have to do to formate the $line['datum'] ? sorry I am a bit of a dummy.... Quote Link to comment 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.