XML timestamp through PHP

Hi I want to automatically generate a current timestamp in XML format when I run my PHP script. How do I do this?

Heres the XML section of my code:

$xml = new XMLWriter();

$xml->openURI("php://output");
$xml->startDocument();
$xml->setIndent(true);

$xml->startElement('Alive');

if($res === FALSE) { 
    die(mysql_error()); // TODO: better error handling
}

while ($row = mysql_fetch_assoc($res)) {
  $xml->startElement("Event");

  $xml->writeAttribute('sessionid', $row['sessionid']);
  $xml->writeAttribute('eventid', $row['eventid']);
  $xml->writeAttribute('BetStatus', $row['BetStatus']);
  $xml->writeAttribute('EventStatus', $row['EventStatus']);
  $xml->writeAttribute('activestatusid', $row['activestatusid']);

  $xml->endElement();
}

$xml->endElement();

header('Content-type: text/xml');
$xml->flush();


Source: xml

Leave a Reply