Skip to content

Instantly share code, notes, and snippets.

@stfnm
Created January 2, 2012 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stfnm/1550076 to your computer and use it in GitHub Desktop.
Save stfnm/1550076 to your computer and use it in GitHub Desktop.
win32 sysuptime
use strict;
use Win32;
my $time = Win32::GetTickCount();
my $days = int($time / 1000 / 60 / 60 / 24);
my $hours = int(($time = ($time - $days * 1000 / 60 / 60 / 24)) / 1000 / 60 / 60);
my $min = int(($time = ($time - $hours * 1000 * 60 * 60)) / 1000 / 60);
my $sec = int(($time = ($time - $min * 1000 * 60)) / 1000);
print "System uptime: $days days, $hours hours, $min minutes, $sec seconds\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment