Jump to content

Formating Date in a php - xml File


rilana

Recommended Posts

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

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.