Created
March 23, 2012 17:29
-
-
Save codereflection/2173032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Convert to ISO 8601 Date time format (Required by Sqlite) | |
/// </summary> | |
/// <param name="dateTime">date to convert</param> | |
/// <returns>date converted to ISO8601 datetime format</returns> | |
public static string ToISO8601(this DateTime dateTime) | |
{ | |
return dateTime.ToString("u").Replace("Z", ""); | |
} | |
public static string ToISO8601(this DateTime? dateTime) | |
{ | |
if(dateTime.HasValue) | |
return dateTime.Value.ToString("u").Replace("Z", ""); | |
return DateTime.MinValue.ToISO8601(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment