This class in PHP can be used to get the uptime of a Windows machine. It uses the creation date of a specific file, by default: 'c:\pagefile.sys'. This method is quite simple and may have some problems, don't use it for critical applications.

Source Code

All source code is online here.

How to use it

require_once ('WindowsUptime.class.php');

$windowsUptime = new WindowsUptime();

echo $windowsUptime->uptime(); // Default output format
echo $windowsUptime->uptime(RAW_OUTPUT);

echo $windowsUptime->upSince(); // Default output format
echo $windowsUptime->upSince('d/M/Y');


0 days 3 hours 21 minutes 17 seconds

10/Sep/2009 @ 17:16