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
0
votes
0 answers

How to configure the deserialization of DateTime string to DateTimeOffset?

Suppose I have this controller action: public HttpResponseMessage AddUser([FromBody] UserInfo info){...} And the class UserInfo has 2 properties: Public string UserName { get; set;} Public DateTimeOffset AddedOn { get; set;} And the following…
Zoomzoom
  • 1,042
  • 2
  • 13
  • 32
0
votes
1 answer

How to get Microsoft Timzone with a city name and country name?

I am not sure whether it is possible. I am simply storing MS timzone info for a local time to my SQL database. There is a way I can provide a city name and country name by the user. but i want my system be able to tell the timezone that city is in…
anIBMer
  • 1,159
  • 2
  • 12
  • 20
0
votes
1 answer

Parsing DateTime with timezone offset with JSON.net

I make a call to a web service, which returns an item, one property of which is: "startDate":"/Date(1398859200000+1100)/" In my C# representation, I have: public class MyClass { public DateTimeOffset StartDate {get; set;} } In my unit test, I…
Alex
  • 37,502
  • 51
  • 204
  • 332
0
votes
1 answer

DateTimeOffset ParseExact - String was not recognized as a valid DateTime

i am trying to parse this date 14.03.2014 22:16:23 using DateTimeOffset.ParseExact but i get String was not recognized as a valid DateTime What i already tried: DateTimeOffset.ParseExact("14.03.2014 22:16:23", "G", new CultureInfo("en-US"))
Roman Ratskey
  • 5,101
  • 8
  • 44
  • 67
0
votes
1 answer

Convert DateTimeOffset to Military time VB.NET

I am needing to convert a DateTimeOffset {2/5/2014 2:28:13 PM -06:00} to Military time of 02/05/2014 14:28:13 and without the PM or the -6:00. SOLVED: I currently have this: row.TimeStamp is DateTimeOffset {2/5/2014 2:28:13 PM -06:00} thisTime =…
theB3RV
  • 894
  • 4
  • 13
  • 33
0
votes
1 answer

Convert Time zonoffset value to varchar

Query: DECLARE @TimeZoneOffset datetimeoffset SELECT @TimeZoneOffset = Time_Zone_Offset FROM OFFSET_TABLE WHERE Active=1 Time_Zone_Offset column contains value like -6:00 (only offset) When I do SELECT @TimeZoneOffset it throws me an…
Sks
  • 612
  • 7
  • 23
0
votes
1 answer

DateTimeOffset adding TimeSpan returns invalid UTC offset for its TimeZoneInfo

I am in the process of building a temporal expression library that must be properly globalized and therefore work in all available Time Zones. Now I seem to be stuck as I'm not sure how to retrieve adjusted dates from DateTimeOffset objects in the…
Perry
  • 528
  • 2
  • 12
0
votes
2 answers

Date Issue when migrating code from WCF to Web API

I'm working on a iOS application, that used to work using WCF. We're changing this product to use MVC Web API instead of WCF. I'm facing a problem with the dates! they must bebin JSON format such like /Date(1373476260000-0600)/ But what is…
Ruba
  • 867
  • 3
  • 11
  • 19
0
votes
1 answer

Representation of a DateTime as the local to remote user

Hello! I was confused in the problem of time zones. I am writing a web application that will contain some news with dates of publication, and I want the client to see the date of publication of the news in the form of corresponding local time.…
0
votes
4 answers

How to get DateTime with a UTC datetime and a particular timezone?

My data in SQL database looks like this: PubDateUTC PubDateUTCOffset ----------------------- -------------------- 2011-08-04 10:02:50.000 +8:00:00 2012-04-23 02:32:25.287 +8:00:00 2010-09-26 04:23:00.000 +8:00:00 What I want is to get…
Edi Wang
  • 3,547
  • 6
  • 33
  • 51
0
votes
1 answer

Why is this iso8601 date parsing with an offset of +2?

I have the following JSON: {"dtime" : "2020-08-26T15:30:00+03:00"} Parsing it, yields the following date: => 2020-08-26 14:30:00 +0200 Why does it have a +2 offset and not a +3 one? EDIT: I'm using Rails 3.2.13, with ActiveSupport 3.2.13. I'm…
Geo
  • 93,257
  • 117
  • 344
  • 520
0
votes
1 answer

Preserving DateTimeOffset Value in Azure DB throught WCF REST

I'm struggling with what I thought should be simple, I've a database table in an azure DB which has a column called "CreatedOn" the datatype of this column in database is "DateTimeOffset". My timezone is IST(+5:30), i'm trying to populate values in…
shashank
  • 123
  • 9
0
votes
1 answer

.net MVC Application server time is different

So my web apis depend a lot on the current time of the user for authorization. The problem is the current time of the user is almost always different from the server's datetime. Was wondering if anybody can give me a suggestion as to how to properly…
gdubs
  • 2,724
  • 9
  • 55
  • 102
0
votes
1 answer

DateTimeOffset value changing

I'm moving data that is currently been stored as a int to DateTimeOffset. Example here is the starting value 1341190841 and when I use this query : dateadd (s,Call.StartTime, '1970-01-01') AS StartTimeDate It returns this value 2012-07-02…
Richard C
  • 389
  • 2
  • 5
  • 16
0
votes
4 answers

IST to EST Time Conversion In Java

I have a Date field in Java in IST Time. I want to convert the same to EST Time and the output should be as a Date Type only. I am able to accomplish the same using the below piece of code:- SimpleDateFormat dateTimeFormat = new…
user2182350
  • 1
  • 1
  • 1
  • 2