Home > Software engineering >  Date format for 7
Date format for 7

Time:12-02

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#?

CodePudding user response:

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();
  •  Tags:  
  • c#
  • Related