I'm having a huge issue with inputting DateTime into my MySQL db. MySQL reads datetime as yyyy-MM-dd HH:mm:ss while C# sees datetime as dd/MM/yyyy HH:mm:ss. I have tried two different examples and both doesn't work.
MODEL
public class DateAndTime
{
public DateTime DateTime { get; set; }
}
CONTROLLER
//I Have two examples that doesn't work.
var myDateTime = "2016-04-08 12:00:00" //this gives the error "cannot covert source 'string' to tartget type System.DateTime
var myDateTime = Convert.ToDateTime("2016-04-08 12:00:00") //this gives the error "Input string was not in a correct format."
var model = new DateAndTime
{
DateTime = myDateTime
};
So I'm stuck. I'ms sure someone out there has had this issue.