C# string to DateTime with timezone -


i want format string : "2012-04-20 10:10:00+0200" datetime format. think must "yyyy-mm-dd hh:mm:ss zzz"?

when tried

   // starttime =  {20/04/2012 10:10:00} without +0200! datetime starttime = convert.todatetime("2012-04-20 10:10:00+0200",cultureinfo.currentculture); // , gave me format exception : {system.formatexception: string not recognized valid datetime.         datetime result = datetime.parseexact("2012-04-20 10:10:00+0200", "yyyy-mm-dd hh:mm:ss zzz", cultureinfo.invariantculture); 

solution given "v4vendetta" :

you should try using datetimeoffset instead of datetime

datetimeoffset result = datetimeoffset.parse("2012-04-20 10:10:00+0200",cultureinfo.invariantculture); 

here offset (2 hrs) computed datetime (10:10) value , desired out put (result.datetime + result.offset)

you should try using datetimeoffset instead of datetime

datetimeoffset result = datetimeoffset.parse("2012-04-20 10:10:00+0200",cultureinfo.invariantculture); 

here offset (2 hrs) computed datetime (10:10) value , desired out put (result.datetime + result.offset)


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -