PHP的Microtime(true)相当于VB.NET?

时间:2012-08-03 15:01:54

标签: php vb.net date timestamp microtime

我正在尝试在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!

任何帮助都会很有意义: - )

1 个答案:

答案 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