How to convert string to date time in specific format and assign it to date property in c# [duplicate]

Wednesday, July 9, 2014

You could try to parse at first the string:



DateTime dt = DateTime.ParseExact(input, "dd/MM/yyyy", CultureInfo.InvariantCulture);


where input is the string with your date, 12/06/2014.


Then you could get the string you want as below:



string output = dt.ToString("yyyy-MM-dd");


For more information about DateTime.ParseExact please look here.







http://ift.tt/1rReu4H