Solved

How do I convert the number in seconds to minutes and seconds for displaying in string

Posted on 2013-06-11
2
248 Views
Last Modified: 2013-06-11
I'm totalling up columns in a GridView to display in the footer, however, the column is the Call Duration of a phone call and the overall total will be in seconds.  However, I need to display it as hours:minutes:seconds as sometimes the total will be > 60 seconds and maybe even more than 3600 seconds. Is there an easy way to do this using myStringSeconds.ToString(xxxxx)??
0
Comment
Question by:Lorna70
2 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39237536
TimeSpan t = TimeSpan.FromSeconds(totalSeconds);

string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", 
    			t.Hours, 
    			t.Minutes, 
    			t.Seconds, 
    			t.Milliseconds);

Open in new window

from http://stackoverflow.com/questions/463642/what-is-the-best-way-to-convert-seconds-into-hourminutessecondsmilliseconds
0
 
LVL 53

Expert Comment

by:Julian Hansen
ID: 39237552
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now