我正在编写一个实体框架4.1应用程序。在这个应用程序中,我有一个定义如下的History类:
public class History
{
public Guid Id { get; set; }
public DateTime HistoryDate { get; set; }
}但是,当我查看数据库时,它似乎将日期存储为本地时间。我的公司不在一个时区,所以这会引起问题吗?我还需要做些什么才能将日期和时间存储为UTC,或者它已经在SQLite中存储为UTC,我只是在我的本地时间看到结果。下面是我看到的一些示例输出:
select id, historydate from history limit 1;
000846d3-f91d-47bb-9963-baf9530e0229|2004-10-28 16:57:00提前感谢!
发布于 2011-06-29 21:22:21
将日期存储在UTC中,并在访问该值时使用ToLocalTime,以使其具有本地时间:http://msdn.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx
https://stackoverflow.com/questions/6521238
复制相似问题