Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite.Net UTC DateTime

I am writing an Entity Framework 4.1 application. In this application I have a History class defined as follows:

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. Here is some sample output of what I see:

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

Thanks in advance!

like image 508
Terry Avatar asked Aug 20 '26 02:08

Terry


1 Answers

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


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!