ASP转换时间为GMT(RFC822)格式时间函数

2010-08-28 10:52:19来源:西部e网作者:

由于VbScript中没有跟GMT相关的时间函数,所以一些Blog或文章系统在生成RSS的时候生成GMT时间(严格的来说是符合RFC822标准)有问题,所以写了如下这个转换函数。

'*************************************
'Coded By hooline 2006.9.8
'Email:hooline#gmail.com
'Msn:peace.zhou#msn.com
'功能:Asp转换时间为GMT(RFC822)格式时间函数
'**************************************
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


函数调用示例:

dim dDate
dDate = now()
dDate = DateTimeToGMT(dDate)
response.write dDate

关键词:ASP

赞助商链接: