由于VbScript中沒有跟GMT相關的時間函數(shù),所以一些Blog或文章系統(tǒng)在生成RSS的時候生成GMT時間(嚴格的來說是符合RFC822標準)有問題,所以寫了如下這個轉(zhuǎn)換函數(shù)。
'*************************************
'Coded By hooline 2006.9.8
'Email:hooline#gmail.com
'Msn:peace.zhou#msn.com
'功能:Asp轉(zhuǎn)換時間為GMT(RFC822)格式時間函數(shù)
'**************************************
Function DateTimeToGMT(sDate)
Dim dWeek,dMonth
Dim strZero,strZone
strZero="00"
strZone="+0800"
dWeek=Array("Sun","Mon","Tue","Wes","Thu","Fri","Sat")
dMonth=Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
DateTimeToGMT = dWeek(WeekDay(sDate)-1)&", "&Right(strZero&Day(sDate),2)&" "&dMonth(Month(sDate)-1)&" "&Year(sDate)&" "&Right(strZero&Hour(sDate),2)&":"&Right(strZero&Minute(sDate),2)&":"&Right(strZero&Second(sDate),2)&" "&strZone
End Function
函數(shù)調(diào)用示例:
dim dDate
dDate = now()
dDate = DateTimeToGMT(dDate)
response.write dDate