Function to format dateTime to RSS 2 pubDate
The following vb.net function will format the date-time to pubDate format for rss 2
Private Function BuildPubDate(ByVal d As Date) As String Try Dim RV As String Dim day As String = d.Day.ToString If day.Length = 1 Then day = "0" & day Dim month As String = d.Month.ToString Select Case month Case "1" month = "January" Case "2" month = "February" Case "3" month = "March" Case "4" month = "April" Case "5" month = "May" Case "6" month = "June" Case "7" month = "July" Case "8" month = "August" Case "9" month = "September" Case "10" month = "October" Case "11" month = "November" Case "12" month = "December" End Select Dim Mtime As String = "" Dim mDate As Date = d.ToUniversalTime If mDate.Hour.ToString.Length = 1 Then Mtime = "0" & mDate.Hour.ToString Else Mtime = mDate.Hour.ToString End If Mtime += ":" If mDate.Minute.ToString.Length = 1 Then Mtime += "0" & mDate.Minute.ToString Else Mtime += mDate.Minute.ToString End If Mtime += ":" If mDate.Second.ToString.Length = 1 Then Mtime += "0" & mDate.Second.ToString Else Mtime += mDate.Second.ToString End If RV = d.DayOfWeek.ToString.Substring(0, 3) RV += ", " & day & " " & month.Substring(0, 3) RV += " " & d.Year.ToString & " " & Mtime & " GMT" Return RV Catch ex As Exception Return "" End Try
Recent Comments