Timezone Strategy

前端 未结 4 1965
情书的邮戳
情书的邮戳 2020-12-13 06:56

I am building a MVC 3 application where the users may not be in the same time zone, so my intent was to store everything in UTC and convert from UTC to local time in the vie

4条回答
  •  醉酒成梦
    2020-12-13 07:37

    This is not possible automatically, you will have to do some manual work.

    1 If you do not want to store user's timezone in db

    1.1 Without masterpage: As csharptest.net suggested use java script's getDateTimeOffset() to get the timezone offset, set value in cookie, write a module to check for cookie if cookie is not present insert java script code and cookie using module.

    1.2 Using masterpage: Same thing but no need to write module for checking.

    2 Store user's timezone in db (best & easiest) No need to use javascript to get timezone just convert datetime according to user's timezone.

提交回复
热议问题