date/time format string (help with reading and writing a specific format)
Posted on 2011-09-21
I need to read and write Date strings using the following format:
9/19/2011 8:10:58 PM
I have code that worked for years with myStreamWriter.WriteLine(Now) and DateTime.Parse(str), but now on a new machine with different locale settings the Parse is choking, and the WriteLine is using a different format. To maintain legacy compatibility, I need to parse and write the timestamp as shown above. I've spend a lot of time going in circles with Parse, and ParseExact, and different Format/Cluture infos, but still can't get it just right.
Any help greatly appreciated.