
Some ASP date conversions I've found useful:
Local Date/Time to UTC Time
Function iso8601date(dLocal,utcOffset)
' convert local time into UTC
d = DateAdd("H",-1 * utcOffset,dLocal)
' compose the date
iso8601date = Year(d) & "-" & Right("0" & Month(d),2) & "-" & Right("0" & Day(d),2)
& "T" & _
Right("0" & Hour(d),2) & ":" & Right("0" & Minute(d),2) & ":" & Right("0" &
Second(d),2) & "Z"
End Function
ISO Date to Date / Time
Function ConvertISODate(isoDateTime)
isoDateTime= trim(isoDateTime)
strDate = Mid(isoDateTime, 1, 4)&"/"&Mid(isoDateTime, 6, 2)&"/"&Mid(isoDateTime,
9, 2)
strTime = Mid(isoDateTime, 12, 2)&":"&Mid(isoDateTime, 15, 2)&":"&Mid(isoDateTime,
18, 2)
ConvertISODate = formatdatetime(strDate & " " & strtime)
End Functions
Date/Time to RFC822 Date
Function Date2RFC822(Date2Convert)
'convert the date to the RFC-822 format
'first declare the variables used:
dim
rfc822timezone,rfc822daydate,rfc822dayno,rfc822day,rfc822monthno,rfc822month,rfc822year,rfc822hour,rfc822minute,rfc822seconds,rfc822time,pubdate
'first we get the input date
'Date2Convert = chkDate(Topic_Last_Post,"",true)
' define your timezone offset below. Examples : "+0100" for GMT+1, "EST", "GMT"
rfc822timezone = " +0200"
'get the date (day)
rfc822daydate = Day(Date2Convert)
if len(rfc822daydate) = 1 then rfc822daydate = "0" & rfc822daydate
'get the number of the day of the week, assuming that monday is the first day of
the week.
rfc822dayno = Weekday(Date2Convert, 2)
' now make sure that this day is translated into the correct english
abbreviation:
select case rfc822dayno
case 1
rfc822day = "Mon"
case 2
rfc822day = "Tue"
case 3
rfc822day = "Wed"
case 4
rfc822day = "Thu"
case 5
rfc822day = "Fri"
case 6
rfc822day = "Sat"
case 7
rfc822day = "Sun"
end select
rfc822monthno = Month(Date2Convert)
' now make sure that this month is translated into the correct english
abbreviation:
select case rfc822monthno
case 1
rfc822month = "Jan"
case 2
rfc822month = "Feb"
case 3
rfc822month = "Mar"
case 4
rfc822month = "Apr"
case 5
rfc822month = "May"
case 6
rfc822month = "Jun"
case 7
rfc822month = "Jul"
case 8
rfc822month = "Aug"
case 9
rfc822month = "Sep"
case 10
rfc822month = "Oct"
case 11
rfc822month = "Nov"
case 12
rfc822month = "Dec"
end select
rfc822year = Year(Date2Convert)
rfc822hour = Hour(Date2Convert) & ":"
if len(rfc822hour) = 2 then
rfc822hour = "0" & rfc822hour
end if
rfc822minute = Minute(Date2Convert) & ":"
if len(rfc822minute) = 2 then
rfc822minute = "0" & rfc822minute
end if
rfc822seconds = second(Date2Convert)
if len(rfc822seconds) = 1 then
rfc822seconds = "0" & rfc822seconds
end if
rfc822time = rfc822hour & rfc822minute & rfc822seconds
'now pu the whole thing together in the RFC822 format
'Example Tue, 21 Dec 2004 22:41:31 +0100
'Example : DDD, dd MMM yyyy, hh:mm:ss timezone
Date2RFC822 = rfc822day & ", " & rfc822daydate & " " & rfc822month & " " &
rfc822year & " " & rfc822time & rfc822timezone
'done
end Function
|