Parse DateTime with time zone of form PST/CEST/UTC/etc

前端 未结 6 687
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 04:28

I\'m trying to parse an international datetime string similar to:

24-okt-08 21:09:06 CEST

So far I\'ve got something like:

         


        
6条回答
  •  既然无缘
    2020-11-22 04:51

    I have two answers because I'm not exactly sure what you are asking.

    1) I see you are using CultureInfo, so if you just want to format the date and time to be culture specific, I would separate the date/time and timezone, apply culture method on the date/time and append the timezone. If "CEST" is different for different cultures, you will have to change it by listing all the options (maybe in a case statement).

    2) If you want date/time to be converted to another timezone, you can't use CultureInfo,

    I suggest reading: http://msdn.microsoft.com/en-us/library/ms973825.aspx

    You can also use the .net framework 3.5 class TimeZoneInfo (different from TimeZone) to make your life easier.

    http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx

提交回复
热议问题