jeudi 21 septembre 2017

Can't properly retrieve the time of an article from an XML file using PHP

I have the next problem. I use some php code to read a xml file and post the link of the articles on my webpage. When I created the page in offline mode and tested it on localhost the time was ok, but now, when I made my webpage online, the time is wrong. I contacted the hosting company and they showed me that the server time is ok. So what can be the problem? I'll let some of my code here so maybe someone can figure it out: First, this is how I load the xml files

        $xml = simplexml_load_file($feed);
        $entries = array_merge($entries, $xml->xpath("//item[position()<=30]"));

And this is where I print the date and time:

foreach($entries as $entry){...
<p ><?= strftime('%d/%m/%Y %I:%M %p', strtotime($entry->pubDate)) ?></p>
...}

So what can be the problem? I don't think that is the code's fault, since on the localhost it prints everything ok. The xml file is ok, I checked the time it gives. And as I said, the hosting company told me the server time is ok.

Thank you all!

Aucun commentaire:

Enregistrer un commentaire