Skip to content

Instantly share code, notes, and snippets.

@robertgreiner
Created December 28, 2011 18:35
Show Gist options
  • Save robertgreiner/1529072 to your computer and use it in GitHub Desktop.
Save robertgreiner/1529072 to your computer and use it in GitHub Desktop.
An example of how to work with custom time strings in C#
//locale information
CultureInfo provider = CultureInfo.InvariantCulture;
//The timestamp from the external file
string dateString = "Dec 07 01:32:25 2009";
//the new format
string format = "MMM dd HH':'mm':'ss yyyy";
//Convert the time string into a legitimate DateTime object
DateTime result = DateTime.ParseExact(dateString, format, provider);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment