time elapsed in days hours minutes (unix to human readable form)

  • Thread starter Thread starter J M
  • Start date Start date
J

J M

I rebooted a network device just few minutes ago and getting device-up-time
value 3191. How do I convert a time elapsed in days hours minutes and
seconds for above value?

Example: This device has been up since 0 days 0 hours x minutes and x
seconds.

TIA!
 
What units is that figure in? If its seconds you could use

double upTime = 3191;
TimeSpan ts TimeSpan.FromSeconds(upTime);
Console.WriteLine("This device has been up since {0} days {1} hours {2} minutes and {3} seconds", upTime.Days, upTime.Hours, upTime.Minutes, upTime.Seconds);

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

I rebooted a network device just few minutes ago and getting device-up-time
value 3191. How do I convert a time elapsed in days hours minutes and
seconds for above value?

Example: This device has been up since 0 days 0 hours x minutes and x
seconds.

TIA!
 
Thanks for reply. Here is how I figure.

I rebooted device for about 5 to 7 minutes and the up time value was 3191 so
here is what I did to fix:

6 minutes = 300 seconds * 10 was close to above value:

TimeSpan ts = new TimeSpan( inputValue * 10 )

Above provided correct value.
 
Back
Top