I have DatetimeOffset value stored as below in my database table :
2002-08-27 07:49:20.3190000 -11:00
Now this is how i write this value in a binary file
:
DateTimeOffset d = "2002-08-27 07:49:20.3190000 -11:00";
BinaryWriter w ;
w.Write(d.Ticks);
Now when i try to read this value using binary reader then it is generating incorrectly like below based on Ticks
:
BinaryReader r;
var dateTime = DateTime.FromBinary(r.ReadInt64());
return new DateTimeOffset(dateTime);
Output : 8/27/2002 7:49:20 AM +05:30
How this is happening?
How to construct exact DatetimeOffset object properly based on Ticks?