Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Core Oracle Timestamp with Timezone to DateTime in c#

With EF Core 2.2.6 I am saving DateTime --> Oracle Timestamp(7) with Time zone : 30.07.19 18:13:23,283000000 +02:00. But when I am reading it back its : 30.07.19 20:13:23,283000000 +02:00.

How can I exlpicitly mention in EF core no DateTime convertions?

like image 774
Srikanth Avatar asked Sep 15 '25 09:09

Srikanth


1 Answers

Dealing with DateTimes and Timezones is between complicated and able to drive you mad. However I have 3 rules that make working with them manageable:

  1. Always store and retrieve the UTC value
  2. Avoid storing or transmission as string
  3. If you can not follow rule 2 (like with XML), at least pick a fixed enconding and culture to use on every endpoint. You really do not want to add those to your worries.

However there are some scenarios (like a Calendar) where you have to deal with timezones instead.

Also note that 0.07.19 18:13:23,283000000 +02:00 is not actually the value. This is a String Representation of the value, using the users settings for details like formating and timezone.

like image 86
Christopher Avatar answered Sep 17 '25 22:09

Christopher



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!