我试图比较一天中两次之间的差异。我正在以 UTC 格式获取时间。我是否必须将 DateTime 转换为整数才能获得差异,如果是,如何?
这是我的代码
Dim ct As DateTime = DateTime.UtcNow
Dim int_ct As Integer = Convert.ToInt32(ct)
MsgBox(ct + " | " + int_ct)
If (System.IO.File.Exists(System.IO.Path.GetTempPath.ToString + "\tempfile.data")) Then
Dim time As DateTime = System.IO.File.ReadAllText(System.IO.Path.GetTempPath.ToString + "\tempfile.data")
Dim int_time As Integer = Convert.ToInt32(time)
If ((int_ct - unlockedtime) < int_time) Then 'unlockedtime is Int variable
Return False
Else
Return True
End If
End If