vb.net 以秒为单位计算时间差
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13988982/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:38:28 来源:igfitidea点击:
Calculating time difference in seconds
提问by Furqan Sehgal
I am using following code to calculate time difference. I want to display it in seconds, not in HH:MM:SS Please advise.
我正在使用以下代码来计算时差。我想在几秒钟内显示它,而不是在 HH:MM:SS 请指教。
Dim myTime = DateTime.Parse("15:40:00 PM")
Dim vrNowTime = DateTime.Parse(TimeOfDay)
Dim result = vrNowTime - myTime
Label1.Text = vrNowTime & " " & myTime
MsgBox(result.ToString)
Thanks
谢谢
回答by Teejay
Use result.TotalSeconds(and round it if you want an integer number to be displayed).
使用result.TotalSeconds(如果要显示整数,则将其四舍五入)。
Also you may want to write simply:
你也可能想简单地写:
Dim result as TimeSpan = Now() - myTime
回答by Mad Dog Tannen
You can also use
你也可以使用
Dim Result = DateDiff(DateInterval.Second,Time1,Time2)

