:::: MENU ::::

Quick tips to solve DateTime confusion in SQLite.Net-PCL

Here is quick tip for this problem.

If you see official documentation in github they mention about the changes of DateTime serialization.

While you are initiating SQLite Connection then it will be configured as storeDateTimeAsTicks enabled. In this condition if you store current DateTime by doing DateTime .Now and read that data as normal DateTime then you will got datetime which is converted to UTC. So quick solutions are

  • Set storeDateTimeAsTicks as false while initaing SQLite Connection.

  • Specify the DateTime value as ToUniversalTime() or ToLocalTime() while storing as well as while reading value.

That’s it. Now your DateTime value will be consistent all time.

Happy coding!!! 🙂

  • Caio

    Good, it works like a charm!