How to elegantly deal with timezones

后端 未结 7 523
庸人自扰
庸人自扰 2020-11-28 17:31

I have a website that is hosted in a different timezone than the users using the application. In addition to this, users can have a specific timezone. I was wondering how ot

7条回答
  •  情深已故
    2020-11-28 18:15

    This is probably a sledgehammer to crack a nut but you could inject a layer between the UI and Business layers which transparently converts datetimes to the local time on returned object graphs, and to UTC on input datetime parameters.

    I imagine this could be achieved using PostSharp or some inversion of control container.

    Personally, I'd just go with explicitly converting your datetimes in the UI...

提交回复
热议问题