简体   繁体   English

SQLite.Net UTC 日期时间

[英]SQLite.Net UTC DateTime

I am writing an Entity Framework 4.1 application.我正在编写一个实体框架 4.1 应用程序。 In this application I have a History class defined as follows:在这个应用程序中,我有一个History class 定义如下:

public class History
{
    public Guid Id { get; set; }
    public DateTime HistoryDate { get; set; }
}

However, when I look in the database, it appears to store the date as local time.但是,当我查看数据库时,它似乎将日期存储为当地时间。 My company doesn't exist in one time zone and so will this cause issues?我的公司不在一个时区,所以这会引起问题吗? Is there something more I need to do to store the date and time as UTC, or is it already stored as UTC in SQLite and I'm just seeing the result in my local time.我还需要做些什么来将日期和时间存储为 UTC,还是已经在 SQLite 中存储为 UTC,而我只是在本地时间看到结果。 Here is some sample output of what I see:这是我看到的一些示例 output:

select id, historydate from history limit 1;
000846d3-f91d-47bb-9963-baf9530e0229|2004-10-28 16:57:00

Thanks in advance!提前致谢!

Store the date in UTC, and use the ToLocalTime when accessing the value to have it in local time: http://msdn.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx将日期存储为 UTC,并在访问该值时使用 ToLocalTime 以使其具有本地时间: http://msdn.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM