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

Discussion in 'ASP .Net' started by 00_CP_D12, Apr 5, 2005.

  1. 00_CP_D12

    00_CP_D12 Guest

    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...
    00_CP_D12, Apr 5, 2005
    #1
    1. Advertising

  2. Use the TimeSpan object.



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en EspaƱol
    Ven, y hablemos de ASP.NET...
    ======================

    "00_CP_D12" <> wrote in message
    news:...
    >
    > 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...
    >
    >
    Juan T. Llibre, Apr 5, 2005
    #2
    1. Advertising

  3. Hours = Seconds / 3600
    Minutes = Seconds / 60

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    What You Seek Is What You Get.

    "00_CP_D12" <> wrote in message
    news:...
    >
    > 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...
    >
    >
    Kevin Spencer, Apr 5, 2005
    #3
  4. 00_CP_D12

    dilipv

    Joined:
    Feb 13, 2008
    Messages:
    1
    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
    dilipv, Feb 22, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    7
    Views:
    16,951
    tshad
    Mar 11, 2005
  2. Stu
    Replies:
    7
    Views:
    1,749
    Dave Thompson
    Mar 7, 2005
  3. Eric

    Time Format in datagrid (Hours, Minutes, Seconds)

    Eric, Aug 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    283
    Alvin Bruney [MVP]
    Aug 12, 2004
  4. `p
    Replies:
    7
    Views:
    366
    Steve Litt
    Dec 14, 2005
  5. lemonhead71
    Replies:
    0
    Views:
    1,380
    lemonhead71
    Oct 3, 2012
Loading...

Share This Page