How to convert a date to UTC properly and then convert it back?

后端 未结 5 2051
心在旅途
心在旅途 2021-02-13 19:48

I\'m struggling with converting DateTime to UTC, the concept and all, something I\'m not understanding correctly.

When I get a date time string, say \"7/10/2013\", I si

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 20:34

    Perhaps it's too early in the morning and I need another cup of coffee, but (at least for display) isn't the solution just using TimeZoneInfo.ConvertTimeFromUtc and specifying the user's desired TZ? Or is the point that ConvertTimeFromUtc does not take into account the date/time at which the conversion back to the desired TZ is being performed? Thinking deeper: even if it does, does anyone know if it takes into account the edge case where the server has shifted to DST but the user's desired TZ has not yet?

提交回复
热议问题