Code
''' -----------------------------------------------------------------------------
''' <summary>
''' Unix时间戳转换成DataTime
''' </summary>
''' <param name="timeStamp"></param>
''' <returns></returns>
''' <remarks>
''' </remarks>
''' <history>
''' [zqonline] 2009-10-30 Created
''' </history>
''' -----------------------------------------------------------------------------
Private Function GetDataTime(ByVal timeStamp As String) As DateTime
Dim dtStart As DateTime = TimeZone.CurrentTimeZone.ToLocalTime(New DateTime(1970, 1, 1))
Dim lTime As Long = Long.Parse(timeStamp & "0000000")
Dim toNow As New TimeSpan(lTime)
Dim dtResult As DateTime = dtStart.Add(toNow)
Return dtResult
End Function
Code
''' <summary>
''' datetime 转成Unix时间戳
''' </summary>
''' <param name="dt"></param>
''' <returns></returns>
Private Function GetUnixTimeStamp(ByVal dt As DateTime) As String
Dim unixStartTime As DateTime = TimeZone.CurrentTimeZone.ToLocalTime(New DateTime(1970, 1, 1))
Dim timeSpan As TimeSpan = dt.Subtract(unixStartTime)
Dim timeStamp As String = timeSpan.Ticks.ToString()
Return timeStamp.Substring(0, timeStamp.Length - 7)
End Function