I want to change the DateTime for MySQL in C#.
My MySQL database only accept this format 1976-04-09 22:10:00.
In C# have a string who have a dat
If your string format for the DateTime is fixed you can convert to the System.DateTime using:
string myDate = "12-Apr-1976 22:10";
DateTime dateValue = DateTime.Parse(myDate);
Now, when you need it in your specific format, you can then reverse the process, i.e.:
string formatForMySql = dateValue.ToString("yyyy-MM-dd HH:mm");
edit - updated code. For some strange reason DateTime.ParseExact wasnt playing nice.