ISO 8601/RFC 3339 Compatible Dates
Posted: October 4, 2009 Filed under: .NET General, Code | Tags: Dates, Extension Methods, ISO, RFC Leave a comment »There are not standard format specifiers for date that takes a date and converts it to an ISO 8601 or RFC 3339 compatible date. Here are two extension methods that does just that.
public static string ToISO8601(this DateTime date)
{
return date.ToString("yyyy-MM-dd");
}
public static string ToRFC3339(this DateTime date)
{
return date.ToUniversalTime().ToString("yyyy-MM-ddThh:mm:ssZ");
}