Ray
Ray

Reputation: 319

Use format specifier with CultureInfo.CurrentCulture

This could be quite a straightforward question, I've tried find a answer but couldn't.

What I'm trying to do is to format my DateTimeOffset to use format specifier "G" and append timezone "zzz" with it. I like to use 'CurrentCulture' as well. myDateTimeOffset.ToString("G zzz", CultureInfo.CurrentCulture)

However, I'm getting result like 'G +12:00'.

I'm expecting to get like '28/07/2016 3:36:31 PM +12'. Any advice to get it to format properly? Thanks.

Upvotes: 0

Views: 302

Answers (1)

candidus
candidus

Reputation: 129

try the following:

string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:G} {0:zzz}", myDateTimeOffset);

Upvotes: 2

Related Questions