Created
December 28, 2011 18:35
-
-
Save robertgreiner/1529072 to your computer and use it in GitHub Desktop.
An example of how to work with custom time strings in C#
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
//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