How to control appearance of ‘:’ in time zone offset when parsing/formatting Datetime

Doesn’t look like there is anything built-in (you can use zz, but that leaves out the minutes).

You can roll your own by instantiating a DateTimeFormatInfo, setting TimeSeparator to string.Empty and using that as the IFormatProvider when calling DateTime.ToString (and make the call explicit, if it is not already).

But frankly, using Replace to remove the unwanted : from the default return value is so much easier.

Leave a Comment