1

My client app is sending me a date string using ISO 8601 format. I can get a DateTime using,

DateTime.Parse(date, null, DateTimeStyles.RoundtripKind);

How to create a .NET DateTime from ISO 8601 format

Now, I wanna know time zone from the string that client is sending. For example, 2022-07-28T01:00:00+02:00 this means client is +2 hours from UTC.

1 Answer 1

4

Don't use the DateTime type. It doesn't know the offset. Use the DateTimeOffset type.

var dateTimeOffset = DateTimeOffset.Parse(date);

Now you can find the offset in the Offset property.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.