Decode XML

I’ve got an XML file an I’m trying to decode the ‘Uptime’ varable to a string but can’t figure out how. I’ve checked Stack Overflow and PHP.net with no luck, I don’t get it. My XML file is at http://cm-pi.xyz/phpsysinfo/xml.php. What can I do?

Thanks,

  • Connor

Uptime is the total number of seconds that the computer has been up or user logged on or whatever.

There are 86400 seconds in a day… from there it’s an easy math problem :wink:

If you have 200644.28 as an uptime take that number and divide by 86400 and you’ll have your answer…

2.322… days or rounded 2.3 days… as for the .3 well again a simple math problem…

that’s bascially 1/3 of a day… so I"m going with 2 days, 8 hours give or take… :wink:

Are you looking for a way to show that?

if so you could possibly do something like this:

[php]

$uptime = shell_exec(“cut -d. -f1 /proc/uptime”);
$days = floor($uptime/60/60/24);
$hours = $uptime/60/60%24;
$mins = $uptime/60%60;
$secs = $uptime%60;
echo “up $days days $hours hours $mins minutes and $secs seconds”;

[/php]

Some of the other guys are way better at this then I am but this is just a suggestion…

I have a MYSQL database with several columns of data.


aliiiiiii

Sponsor our Newsletter | Privacy Policy | Terms of Service