How to convert Seconds to X Hours Y Minutes Z Seconds?

0

00_CP_D12

Is there an easy way in ASP.NET to convert seconds to Hours: Minutes:
Seconds?

For example, 65 seconds will return 0 hr, 1 min, 5 secs.

Thanks...
 
K

Kevin Spencer

Hours = Seconds / 3600
Minutes = Seconds / 60

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Joined
Feb 13, 2008
Messages
1
Reaction score
0
Converting hours to minutes

hi ther,
just try out the following given solution it might help you out.


Int64 seconds = 19800;
TimeSpan span = new TimeSpan(TimeSpan.TicksPerSecond * seconds);
string str = span.Hours.ToString("00") + ":" + span.Minutes.ToString("00") + ":" + span.Seconds.ToString("00");
Response.Write(str)

hope this will help you out

Thank you
Jitesh
Programmer
.Net Consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,834
Latest member
BuyCannaLabsCBD

Latest Threads

Top