Welcome Guest, Not a member yet? Register   Sign In
Reformat XML 'date' output.

Thanks for your response. While it is true that this is one way to get the dates formatted, what I was not able to reason was how to save the newly formatted values back into the "$query" variable and then have them sent to the xml_from_result function.

My solution is as follows and relies on the MYSQL code to format the date for output. This is an awfully convenient solution to the problem.

$query = $this->db->query("SELECT DATE_FORMAT(date, '%m.%d.%y') as date_formatted FROM news ORDER BY date DESC");

$config = array (
    'root'    => 'news',
    'element' => 'item',
    'newline' => "\n",
    'tab'    => "\t"

$data = $this->dbutil->xml_from_result($query, $config);
write_file("./data/news.xml", $data);

Do you see any reason not to go this route?

For the sake of learning a little, could you show me how you'd take those formatted dates and store them back into the $query variable? I'm always up for learning something new!

Messages In This Thread
Reformat XML 'date' output. - by El Forum - 11-13-2008, 11:03 PM
Reformat XML 'date' output. - by El Forum - 11-14-2008, 09:09 AM
Reformat XML 'date' output. - by El Forum - 11-14-2008, 10:26 AM

Theme © iAndrew 2016 - Forum software by © MyBB