I’m storing timestamps in my xml document, but when trying to use them as comparing to the current timestamp it is not working? I have also tried to get it to work with date() but it won’t? What am I doing wrong?
XML looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
<game id="83832">
<opponent>Danielle</opponent>
<oppid>101</oppid>
<lastdraw>1</lastdraw>
<turn>1</turn>
<image>101b.png</image>
<nextdraw>1348156426</nextdraw>
<infopop>0</infopop>
<playertilesum>89</playertilesum>
<oppnation>0</oppnation>
</game>
<game id="89939">
<opponent>Bigscreen</opponent>
<oppid>107</oppid>
<lastdraw>3</lastdraw>
<turn>2</turn>
<image>107a.png</image>
<nextdraw>1347913606</nextdraw>
<infopop>0</infopop>
<playertilesum>101</playertilesum>
<oppnation>0</oppnation>
</game>
</data>
And what I try to do is this:
$timestamp = $_SERVER['REQUEST_TIME'];
$xml=simplexml_load_file('TEST.xml');
foreach ($xml->game as $game) {
if($game->nextdraw < $timestamp){
echo '['.$r.'] '.$game->nextdraw.'<br>';
}
}
I only want to show the games which is not older than the timestamp? Am I doing this all wrong?
I do not see anything wrong in your code. I ran it and got:
What are you getting?
UPDATE: In order to check if the condition is executed correctly, use the following
foreachloop instead.}