asp.net - convert "Thu May 29 2014 12:00:00 GMT-0700" to DateTime -


i'm having problem convert "thu may 29 2014 12:00:00 gmt-0700" datetime

error: i'm sending value hidden field in js , code behind keep crashing error "string not recognized valid datetime".

dim fromdate string = hfdatefrombylocation.value dim todate string = hfdatetobylocation.value  dim retvalfromdate datetime = datetime.parseexact(fromdate, "ddd mmm dd hh:mm:ss kkkk yyyy", cultureinfo.invariantculture) dim retvaltodate datetime = datetime.parseexact(todate, "ddd mmm dd hh:mm:ss kkkk yyyy", cultureinfo.invariantculture) 

had work out, got work format string , using datetimeoffset.parseexact not datetime

"ddd mmm dd yyyy h:mm:ss 'gmt'kkkkk"

it's gmt bit doesn't like. wrapped in quotes , need k minus sign..

bit more investigation, can use datetime.parseexact lose time zone offset. datetime correct, in takes offset account, don't know how 'much' of offset.

"ddd mmm dd yyyy h:mm:ss 'gmt'zzz" worked me.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -