-1

I have this kind of date format:

2022-11-17T15:23:45+07:00

I want to try the following, but I don't know what format should I use in here for +7?

 DateTime startDateTime = DateTime.ParseExact(sessionDate, "yyyy-MM-ddTHH:mm:ss",
 System.Globalization.CultureInfo.InvariantCulture).ToUniversalTime();

How to convert it into UTC+0 with C#?

Dev
  • 107
  • 6
  • Does this answer your question? [How does DateTime.ToUniversalTime() work?](https://stackoverflow.com/questions/1201378/how-does-datetime-touniversaltime-work) – Alp Dec 02 '22 at 06:42

1 Answers1

3

The +7 is the offset relative to UTC.

To convert that to UTC+0:

var utc = DateTime.Parse("2022-11-17T15:23:45+07:00").ToUniversalTime();
Brendan Green
  • 11,676
  • 5
  • 44
  • 76