By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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!
Nov 16 '05 #2

P: n/a
J M
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.
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:eu*************@TK2MSFTNGP11.phx.gbl...
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!

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.