Featured post
asp.net mvc - C# DateTime.ParseExact throwing format exception -
i'm developing .net4 webapplication using mvc3.
let's i'm getting following datetime string xml-feed. xml feed being read application , i'm looping through it's descendants. datetime i'm receiving begin returned in following format (as string);
var mydatetime = "sun dec 19 11:45:45 +0000 2010"
i'm using piece of code below try , parse datetime string mentioned above valid datetime format (preferably dutch)
var correctdatetime = datetime.parseexact(mydatetime , "dd mmm yyyy hh:mm:ss", cultureinfo.invariantculture);
when trying execute code i'm facing formatexception. has got ideas?
--update--
this i've got after various answers. still throwing same exception though.
var correcteddatetime = datetime.parseexact(latesttweettime, "ddd mmm hh:mm:ss k yyyy", cultureinfo.invariantculture); string display = correcteddatetime.tostring("dd mmm yyyy hh:mm:ss");
if you're trying read this: "sun dec 19 11:45:45 +0000 2010"
you need additional "d" or "dd" so:
"ddd mmm d hh:mm:ss k yyyy"
or
"ddd mmm dd hh:mm:ss k yyyy"
depending on whether input zero-prefixed.
you need each piece of input string accounted for, here summary of different components msdn: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
ddd = 3 letter day of week mmm = 3 letter month dd = 2 digit day of month 01-31 (use "d" 1-31) hh = hours using 24-hour clock. 00-24 (use "h" 0-24) mm = minutes. 00-59 ss = seconds. 00-59 k = time zone information yyyy = 4-digit year
- Get link
- X
- Other Apps
Comments
Post a Comment