問題描述
更改會員等級時區 (change membership class time zone)
I noticed recently that when I create new users using the Membership Class
all of the time fields like LastActivityDate
are saved as UTC
(4hrs ahead of my time zone). I thought there might be a value to change in the web.config
to use my time zone but there isn't, this is all that is available.
Is there a way to change which time zone is used by the membership class or is this one of those things that CANNOT be changed because it is standard practice to use UTC
‑‑‑‑‑
參考解法
方法 1:
The LastActivityDate is saved on UTC, but when you read it is converted to the LocalTime of the server. This is the code when you call to view it.
public virtual DateTime LastActivityDate
{
get
{
return this._LastActivityDate.ToLocalTime();
}
}