ISO 8601/RFC 3339 Compatible Dates

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");
}

Follow

Get every new post delivered to your Inbox.