Function ToUnixTime(strTime, intTimeZone) If IsEmpty(strTime) or Not IsDate(strTime) Then strTime = Now If IsEmpty(intTimeZone) or Not isNumeric(intTimeZone) Then intTimeZone = 0 ToUnixTime = DateAdd("h",-intTimeZone,strTime) ToUnixTime = DateDiff("s","1970-01-01 00:00:00", ToUnixTime)End Function"把UNIX時間戳轉換為標準時間Function FromUnixTime(intTime, intTimeZone) If IsEmpty(intTime) or Not IsNumeric(intTime) Then FromUnixTime = Now() Exit Function End If If IsEmpty(intTime) or Not IsNumeric(intTimeZone) Then intTimeZone = 0 FromUnixTime = DateAdd("s", intTime, "1970-01-01 00:00:00") FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)End Function"呼叫方法:"示例:ToUnixTime("2009-12-05 12:52:25", +8),返回值為1259988745 "response.Write ToUnixTime("2009-12-05 12:52:25", +8)"示例:FromUnixTime("1259988745", +8),返回值2009-12-05 12:52:25 "response.Write FromUnixTime("1259988745", +8)
ASP時間戳函式"把標準時間轉換為UNIX時間戳
Function ToUnixTime(strTime, intTimeZone) If IsEmpty(strTime) or Not IsDate(strTime) Then strTime = Now If IsEmpty(intTimeZone) or Not isNumeric(intTimeZone) Then intTimeZone = 0 ToUnixTime = DateAdd("h",-intTimeZone,strTime) ToUnixTime = DateDiff("s","1970-01-01 00:00:00", ToUnixTime)End Function"把UNIX時間戳轉換為標準時間Function FromUnixTime(intTime, intTimeZone) If IsEmpty(intTime) or Not IsNumeric(intTime) Then FromUnixTime = Now() Exit Function End If If IsEmpty(intTime) or Not IsNumeric(intTimeZone) Then intTimeZone = 0 FromUnixTime = DateAdd("s", intTime, "1970-01-01 00:00:00") FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)End Function"呼叫方法:"示例:ToUnixTime("2009-12-05 12:52:25", +8),返回值為1259988745 "response.Write ToUnixTime("2009-12-05 12:52:25", +8)"示例:FromUnixTime("1259988745", +8),返回值2009-12-05 12:52:25 "response.Write FromUnixTime("1259988745", +8)轉載來源網路