Date conversion issue

Date conversion issue



Solution


string strDate = "dd/MM/yyyy HH:mm:ss";

try
{
 dateTime = DateTime.ParseExact(strDate, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
}
catch
{
 dateTime = DateTime.ParseExact(strDate, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
}

  

Hope this will help you and save your time.

Enjoy !!!

:)

No comments:

Post a Comment