Solved

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

Posted on 2013-06-11
2
250 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 54

Expert Comment

by:Julian Hansen
ID: 39237552
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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