How to convert seconds to HH:MM:SS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meettapan
    New Member
    • Jun 2007
    • 9

    How to convert seconds to HH:MM:SS

    Write a C# program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (for example, if the elapsed time is 9630 seconds, then the output is 2:40:30.)

    Can anyone pls help me!!
    Im using visual studio 2005
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Here is a search that may help:
    c# How to convert seconds to HH:MM:SS

    Comment

    • balabaster
      Recognized Expert Contributor
      • Mar 2007
      • 798

      #3
      Originally posted by kenobewan
      Here is a search that may help:
      c# How to convert seconds to HH:MM:SS
      Minutes = (Seconds \ 60) '(This will convert your seconds to whole minutes)
      Hours = (Minutes \ 60) '(This will convert your minutes to whole hours
      Days = (Hours \ 24)
      Weeks = (Days \ 7)
      Months gets tricky because none of them are the same length
      Seconds = Seconds Mod 60 '(This will give you the remaining seconds)
      You should be able to figure out the rest from there...use mod to get remaining parts like I demonstrated with the seconds.
      So: (Hours Mod Minutes) will get you the remaining minutes outside the hour etc etc...

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by balabaster
        So: (Hours Mod Minutes) will get you the remaining minutes outside the hour etc etc...
        I think you mean hours mod 60.

        Comment

        • balabaster
          Recognized Expert Contributor
          • Mar 2007
          • 798

          #5
          Originally posted by Motoma
          I think you mean hours mod 60.
          That'll teach me to answer questions as I'm rushing out the door...hehe.

          Sorry, I meant minutes mod 60...houirs mod 60 wouldn't give you much of interest as there's 24 hours in a day, not 60 hours in a day ;)

          Comment

          • Motoma
            Recognized Expert Specialist
            • Jan 2007
            • 3236

            #6
            Originally posted by balabaster
            That'll teach me to answer questions as I'm rushing out the door...hehe.

            Sorry, I meant minutes mod 60...houirs mod 60 wouldn't give you much of interest as there's 24 hours in a day, not 60 hours in a day ;)
            Haha, that will teach me to respond snidely while rushing :D
            Cheers!

            Motoma

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              I think you all ment to say:

              Sorry, we don't do school projects here. Try working it out yourself and if you have any specific questions regarding code, please feel free to ask those.

              Comment

              • balabaster
                Recognized Expert Contributor
                • Mar 2007
                • 798

                #8
                Originally posted by Plater
                I think you all ment to say:

                Sorry, we don't do school projects here. Try working it out yourself and if you have any specific questions regarding code, please feel free to ask those.
                Yes that's exactly what we meant...I guess sometimes it just takes a different pair of eyes :oP

                Comment

                • Haseeb lala
                  New Member
                  • Dec 2014
                  • 1

                  #9
                  yes i will help u man meettapan.
                  but i m use Turbo c++

                  Comment

                  Working...