Convert Difference between 2 times into Milliseconds?

后端 未结 11 2161
梦毁少年i
梦毁少年i 2020-12-06 09:11

I have two masked TextBox controls and was wondering how I\'d go about getting the time in each one and then converting the difference into milliseconds. Like, say in tb1 I

11条回答
  •  感情败类
    2020-12-06 09:42

    Try the following:

       DateTime dtStart;
       DateTime dtEnd;
    
       if (DateTime.TryParse( tb1.Text, out dtStart ) && DateTime.TryParse(tb2.Text, out dtEnd ))
       {
          TimeSpan ts = dtStart - dtEnd;
          double difference = ts.TotalMilliseconds;
       }
    

提交回复
热议问题