WebMatrix Helper controlled table showing wrong time in Password Change Date field

∥☆過路亽.° 提交于 2019-12-11 02:49:41

问题


everyone,

I have a quick question. Can anyone tell me why the field "PasswordChangeDate" in the helper controlled table "webpages_Membership" (automatically filled using the Web.Security Helper, I'm pretty sure) is logging a date/time that is 5 hours off? I just changed my password and looked at the field and saw that while I had changed my password at 10:50 AM, it showed 3:50 PM. Is there a setting somewhere (possibly for time zone, etc.) that I need to adjust within the Web.Security helper? One thing I do know is that when I go to the "Site" section in WebMatrix, in the "Request" tab, it IS in fact showing the correct timestamps for my requests here.

Any help is very much appreciated!


回答1:


The SimpleMembership Provider uses UTC DateTimes, so presumably your time zone is UTC - 5 (or somewhere on the eastern side of the USA). You can either implement your own Membership Provider and override all the methods that insert a DateTime value into the membership database, or convert the stored time to one of your preferred time zone using the TimeZoneInfo.ConvertTimeFromUtc method.

What you can do if it is important for you to display the local time that a user registered or changed their password is to ask them what time zone they are in when they register. You can then store the offset form UTC as part of their profile, and use that with the DateTime.AddHours method to calculate the time in their time zone.



来源:https://stackoverflow.com/questions/13090475/webmatrix-helper-controlled-table-showing-wrong-time-in-password-change-date-fie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!