emelia emelia - 1 year ago 107
C# Question

C#: Parse Datetime.Now to specific fromat

I want to parse

into formatted string like


Answer Source

You can't parse DateTime.Now. It already returns a DateTime, not a string.

You can generate it's string string representation using yyyy-MM-dd'T'HH:mm:ss.fffffff'Z' format with a proper culture like InvariantCulture;

DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'", CultureInfo.InvariantCulture)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download