Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-11
2
Medium Priority
?
258 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:
Meir Rivkin earned 1000 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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

971 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