Convert rss pubDate to EST in .NET
-
20-09-2019 - |
Question
I am trying to convert the pubDate in the Rss to EST. If you look at the links posted below, they have different timezones. Is there a function which takes any type of dateformat and convert to EST ?
http://rss.cnn.com/rss/cnn_topstories.rss
http://www.cricinfo.com/rss/content/story/feeds/0.rss
http://feeds.latimes.com/latimes/entertainment?format=xml
http://newsrss.bbc.co.uk/rss/newsonline_world_edition/business/rss.xml
Solution
Take a look at the ConvertTime method. For example:
var s = "Mon, 21 Dec 2009 14:09:45 GMT";
var date = DateTime.Parse(s, CultureInfo.InvariantCulture);
var est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var estDate = TimeZoneInfo.ConvertTime(date, est);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow