Get value
entity.ExpiredDate = ParseDate(model.ExpiredDate);
private static DateTime ParseDate(string input)
{
return DateTime.ParseExact(input, formats, CultureInfo.InvariantCulture, DateTimeStyles.None);
}
private static string[] formats = new string[]
{
"MM/dd/yyyy HH:mm:ss tt",
"MM/dd/yyyy HH:mm:ss",
"M/dd/yyyy H:mm:ss tt",
"M/dd/yyyy H:mm:ss" ,
"MM/dd/yyyy hh:mm tt"
};
Set Value
viewModel.ExpiredDate = entity.ExpiredDate.ToString("MM/dd/yyyy hh:mm tt", CultureInfo.InvariantCulture);
Comments
Post a Comment