php - Count the number of days from Twitter XML -


i'm using twitter api recent tweets xml file website. have tweets displaying on page can't show how many days have passed since displaying tweet.

i've tried solutions answered here same problem didn't work me. date , time xml file given folows:

<statuses type="array">    <status>       <created_at>sat mar 23 18:43:16 +0000 2013</created_at>    </status> </statuses> 

i'm retrieving data this:

<?php $xmldata = 'https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=ablazedigital'; $open = fopen($xmldata, 'r'); $content = stream_get_contents($open); fclose($open); $xml = new simplexmlelement($content); ?> <?php      echo $xml->status[0]->created_at; ?> 

how can make function php reads follwing date "sat mar 23 18:43:16 +0000 2013" , tells how many days have passed present day?

$now = new datetime('now'); $pagetime = new datetime('sat mar 23 18:43:16 +0000 2013');  $sub = $now->diff($pagetime); $days = $sub->format('%d');  if ($days < 1) {     echo 'less day has passed'; } elseif ($days == 1) {     echo $days.' day has passed'; } else {     echo $days.' days have passed'; } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -