简体   繁体   English

PHP的Microtime(true)是否等效于VB.NET?

[英]PHP's Microtime(true) Equivalent For VB.NET?

I am trying to regenerate PHP's microtime(true) in VB.NET to create a microtime (1344004866.8658) although I am not having much luck! 我想在VB.NET中重新生成PHP的microtime(true)以创建一个microtime(1344004866.8658),尽管我运气不佳!

I have searched all over the net & cannot seem to find any help around for this one! 我在网上搜索了所有内容,似乎找不到任何帮助!

I am using the following function to create a standard Unix timestamp: 我正在使用以下函数来创建标准的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

Although am completely lost as to how I would change this function to create a microtime! 虽然我完全不知道如何更改此功能以创建微型时间!

Any help would be much appretiated :-) 任何帮助将不胜感激:-)

Ah, finally found something & ammended it for daylight saving which helped: 啊,终于找到了一些东西并针对夏令时进行了修改,这有所帮助:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM