"Tue Apr 07 22:52:51 +0000 2009"
If you are like me, you may prefer to have this converted into a .NET Date or DateTime object. This is easy enough to do with the .ParseExact method on a Date object. We just have to provide it a date format for which we are inputting. The magic date formula for the Twitter "created_at" date is as follows: "ddd MMM dd HH:mm:ss zzz yyyy"
The following code shows how to convert this string into a valid date:
You might actually do this as part of a LINQ query, and in that case, you might have something within your query that looks similar to the code below:
Dim TwitterStringDate As String = "Tue Apr 07 22:52:51 +0000 2009"
Dim TwitterDate As Date = Date.ParseExact(TwitterStringDate, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture)
.PublishDate = If(xe.
.Value IsNot Nothing, Date.ParseExact(xe. .Value, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture), Date.MinValue)
Thank you, this helped so much.ReplyDelete
Thanks, exactly what I was looking for.ReplyDelete
Thanks for this -- very helpful.ReplyDelete
Fantastic post, just been stung by the API deprecation and this has saved me alot of time.ReplyDelete
You saved my day! :)ReplyDelete