none
Convert Integer Value to time RRS feed

  • Question

  • Hi

    Is there any function or method to convert a given integer value to time value,

    for eg: 61  converted to -->>   01:01:00   (Format => hh:mm:ss)

    Thursday, March 22, 2007 5:36 AM

Answers



  • label1.Text = String.Format("{0:00}:{1:00}:{2:00}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

     

    Thursday, March 22, 2007 3:53 PM

All replies

  • Assuming the integer value represents seconds (otherwise you'll have to look at the other overloads of the TimeSpan constructor)

    int number = 61;
    TimeSpan timeSpan = new TimeSpan( 0, 0, number );
    Console.WriteLine( "{0:00}:{1:00}:{2:00}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds );

    Thursday, March 22, 2007 7:07 AM
  • hi

    thank u for the solution.

    int number = 61;
    TimeSpan timeSpan = new TimeSpan( 0, 0, number );
    Console.WriteLine( "{0:00}:{1:00}:{2:00}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds );

    can u send me the code to show this output in Label or textbox control

    Thursday, March 22, 2007 8:23 AM


  • label1.Text = String.Format("{0:00}:{1:00}:{2:00}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

     

    Thursday, March 22, 2007 3:53 PM
  • Hi!

    Thank u for the solution.

    regards james

    Friday, March 23, 2007 4:00 AM