由于VbScript中沒有跟GMT相關(guān)的時(shí)間函數(shù),所以一些Blog或文章系統(tǒng)在生成RSS的時(shí)候生成GMT時(shí)間(嚴(yán)格的來說是符合RFC822標(biāo)準(zhǔn))有問題,所以寫了如下這個(gè)轉(zhuǎn)換函數(shù)。
'*************************************
'Coded By hooline 2006.9.8
'Email:hooline#gmail.com
'Msn:peace.zhou#msn.com
'功能:Asp轉(zhuǎn)換時(shí)間為GMT(RFC822)格式時(shí)間函數(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