5
Answers

calculating time duration

janine valenzona

janine valenzona

15y
3.7k
1
hi.. please check this code of mine:

 protected void Button4_Click(object sender, EventArgs e)
    {
        DateTime dt1;
        DateTime dt2;

        string currenttime1 = DateTime.Now.ToLongTimeString();
        string currenttime2 = DateTime.Now.ToLongTimeString();
        TextBox2.Text = currenttime2;

        dt1 = Convert.ToDateTime(currenttime1);
        dt2 = Convert.ToDateTime(currenttime2);

       
        TimeSpan ts = dt1 - dt2;

        int hours = ts.Hours;
        int min = ts.Minutes;

      

      
        string finalMin = Convert.ToString(min);


        TextBox3.Text = finalMin;
       

---- i'm having a web page that calculated time duration when the user press the stop button.. but the output of this code is always zero.. what is my error?
thanks in advance.. :)
--im using asp.net and C#
Answers (5)
1
Ramesh Palaniappan
NA 13.2k 722.6k 8y
  1. [WebBrowsable(true),
  2. WebDisplayName("ListName"),
  3. WebDescription("ThisAcceptstextInput"),
  4. Personalizable(PersonalizationScope.Shared),
  5. Category("WarrantyMessages")]
  6. publicstringlistName{get;set;}
above code will add webpart property name "List Name"
Accepted