Possible duplicate:
Build Date Display
How do I know when Windows was started or shut down?
for my purposes I am writing a C # executable that will calculate the time (minutes) difference from the point in time and time of the last server reboot.
I am currently collecting and analyzing the output from cmd β "net stats server" and creating a new DateTime object, and then comparing it with DateTime.Now with a TimeSpan object.
Is there a cleaner way to do this without using third party downloads ? I am afraid that not all date formats from "net stats server" are in the format that I expect.
** edit my bad, this is a duplicate, but for what was worth my decision, it was this:
float ticks = System.Environment.TickCount; Console.WriteLine("Time Difference (minutes): " + ticks / 1000 / 60); Console.WriteLine("Time Difference (hours): " + ticks / 1000 / 60 / 60); Console.WriteLine("Time Difference (days): " + ticks / 1000 / 60 / 60 / 24);
Kevin zhou
source share