Questions tagged [datetimeoffset]

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

Contrary to popular belief (and to much of the documentation) the offset provided does not represent a time zone. One might start with a time zone to obtain the offset, but it is a one-way function. You can not determine the time zone by the offset alone. For a better understanding of this, see this community wiki answer.

The preferred serialization format for this type of data is defined as part of the ISO-8601 specification.

  • Example: 1997-07-16T19:20:30+01:00

DateTimeOffset and similar structures are presented in:

Please update this list if you are aware of similar structures in other languages, frameworks, or databases

614 questions
8
votes
1 answer

How to store DateTimeOffset in PostreSQL

I am having a problem with retrieving a DateTimeOffset from a PostgreSQL database using Entity Framework. As far as researching the problem, I found this article that helps me understand what the problem is, but I can't figure out how to fix it. I…
GBreen12
  • 1,832
  • 2
  • 20
  • 38
8
votes
1 answer

DateTimeOffset resolution in c# and SQL Server

Docs state that in both .NET and SQL server the resolution is 100ns. The time component of a DateTimeOffset value is measured in 100-nanosecond units called ticks - C# Accuracy - 100 nanoseconds - SQL Server However SQL seems to drop the last digit…
Evgeni
  • 3,341
  • 7
  • 37
  • 64
8
votes
4 answers

There is a difference between local and server time

In MVC4 C# application I used DateTime.Now when object created in my application. After deploying, there was +8 hours difference between local computer and hosting. Then I changed it to DateTime.UtcNow, now difference is -4 hours. For example in my…
Jeyhun Rahimov
  • 3,769
  • 6
  • 47
  • 90
8
votes
2 answers

SQL Server DateTimeOffset matching same "day"

My application needs to collect "Tuesday's" purchases for all locations world wide, where "Tueday" is the location's Tuesday (regardless of time zone). And if the user needs to re-run the report next week, I need to still get "Last Tuesday's" data.…
DeborahK
  • 57,520
  • 12
  • 104
  • 129
7
votes
3 answers

"TIMESTAMP WITH TIME ZONE" <--> DateTImeOffset mapping won't deliver the Zone part on INSERT commands (Entity Framework + Oracle)

I use EF (EDMX model - DB first) to map "TIMESTAMP WITH TIME ZONE" to a DateTimeOffset. when I commit the DateTimeOffset to Oracle, the Zone part is saved incorrectly. So if using the model, for example, to insert the value 29/02/2012 10:10:10…
EliH
  • 71
  • 1
  • 3
7
votes
3 answers

Migration from local server to Azure: TIMEZONE UTC. How to solve?

I designed my application considering the fact that, according to the specifications, should run on a server located in Italy and clients will be italian people only. About a month ago, my bos decided to bring it all on Azure. Everything went…
Marco Staffoli
  • 2,475
  • 2
  • 27
  • 29
7
votes
3 answers

How to convert an Epoch to a OffsetDateTime in Kotlin?

The postgresql Timestamp with Time Zone data type needs to be supplied an OffsetDateTime when being called using a High level language like Kotlin. I could not find a direct method that supports Epoch to OffsetDateTime conversion.
Raj
  • 3,637
  • 8
  • 29
  • 52
7
votes
1 answer

Time difference calculation error

I have to calculate total fly time minutes between departure airport and arrival airport. This job is done by this code snippet: public int calculateFlightDuration(String departureDateTime, String depAirportCode, String arrivalDateTime, …
7
votes
1 answer

DateTimeOffset parse and custom time zone

We are parsing XML DateTime values into a DateTimeOffset value. According to the W3C XSD documentation for DateTime, the type may have a timezone info or not. Our requirment says: If time zone info is provided in XML, use this time zone If no…
Thomas Zweifel
  • 627
  • 1
  • 6
  • 19
7
votes
4 answers

QuickBooks Web Connector TimeModified offset does not account for Daylight Savings time

I'm using QuickBooks Web Connector to pull employee records out of QuickBooks Desktop on a Windows 8.1 machine using QBXML requests. Is there a reason the TimeModified time stamps are returning an offset that does not account for Daylight Savings…
antibrian
  • 346
  • 4
  • 12
6
votes
1 answer

DateTimeOffset proper usage

If I have a DateTime instance which represents a valid UTC time, and an offset that converts that DateTime to the time zone where it applies, how do I construct a DateTimeOffset instance to represent this? var utcDateTime = new DateTime(2011, 02,…
Barg
  • 2,968
  • 7
  • 26
  • 28
6
votes
2 answers

WCF DateTimeOffset compatibility

I have a .NET WCF service with a few operation contracts that takes a DateTimeOffset. The idea is to avoid any confusion with DST and time zones. However I am in doubt that using DateTimeOffset is a good idea after all, since it is fairly…
Holstebroe
  • 4,993
  • 4
  • 29
  • 45
6
votes
3 answers

Get time zone offset between two timezones for a given duration

I wanted to know if there is a way to get the time zone offset for a given date range between two timezones for a given duration. getTimezoneOffset(startDate,endDate,timezone1,timezone2){ ...missing magic to go here... } should return the time…
user1192612
  • 61
  • 1
  • 3
6
votes
4 answers

How many days to add for "semi-monthly"

I have a enum type called PaymentFrequency whose values indicate how many payments per year are being made... So I have public enum PaymentFrequency { None = 0, Annually = 1, SemiAnnually = 2, …
zam6ak
  • 7,229
  • 11
  • 46
  • 84
6
votes
1 answer

Converting DateTime.MinValue to DateTimeOffset

I am trying to convert DateTime.MinValue to a DateTimeOffset value but am getting an ArgumentOutOfRange exception. I was looking at the the MSDN article on implicit conversions of DateTime to DateTimeOffset and the Exception section states that…
Mr Moose
  • 5,946
  • 7
  • 34
  • 69