我正在尝试在VB.NET中重新生成PHP的microtime(true)以创建一个microtime(1344004866.8658),尽管我没有太多运气!
我在网上搜索了整个网络。似乎无法为这个找到任何帮助!
我使用以下函数创建标准Unix时间戳:
Public Function TimeToUnix(ByVal dteDate As Date) As String
If dteDate.IsDaylightSavingTime = True Then
dteDate = DateAdd(DateInterval.Hour, -1, dteDate)
End If
TimeToUnix = DateDiff(DateInterval.Second, #1/1/1970#, dteDate)
End Function
虽然我完全失去了如何更改此功能以创建microtime!
任何帮助都会很有意义: - )
答案 0 :(得分:0)
Public Function GetUnixMicroTime(ByVal dates As DateTime) As String
If dates.IsDaylightSavingTime = True Then
dates = DateAdd(DateInterval.Hour, -1, dates)
End If
Dim origin As DateTime = New DateTime(1970, 1, 1, 0, 0, 0, 0)
Dim diff As TimeSpan = dates - origin
Return CStr(diff.TotalSeconds)
End Function