rmh rmh - 2 years ago 171
C# Question

How to parse Timezone Offset string?

I retrieve a value from my database of a timeZone offset. The value that I get is in time.

For example, it could be

, etc.

How do I convert that to a double so I can do an
call on a

Answer Source

Use the TimeSpan.Parse method:

var time = "+7:30";
time = time.Replace("+", "");  // Remove the + if it is there.

var hours = TimeSpan.Parse(time).TotalHours;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download