Sunday, May 02, 2010

The ISO 8601 format string

/// <summary>
/// The ISO 8601 format string.
/// </summary>

private const string Iso8601Format = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'";

//SortableDateTimePattern (ISO 8601)
public static string ToIso8601(DateTime value)
return value.ToUniversalTime().ToString(Iso8601Format, CultureInfo.InvariantCulture);

public static DateTime ParseIso8601(string value)
return DateTime.ParseExact(value,
Iso8601Format, CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);

No comments:

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: Its free and easy to use, we provide all sources at codeplex.

Facebook Badge