c# 4.0 - String Conversation to DateTime -
i facing problem while converting string datetime.it gives me "string not recognized valid datetime" exception.
here input string
10/28/2014 3:13:12 am"
code snippet
datetime dt = datetime.parseexact("10/28/2014 3:13:12 am", "dd-mmm-yyyy hh:mm", cultureinfo.invariantculture);
i have gone through couple of stack overflow posts still having same issue.
reference post string not recognized valid datetime in c# asp.net
use format string: "mm/dd/yyyy h:mm:ss tt"
:
datetime dt = datetime.parseexact("10/28/2014 3:13:12 am", "mm/dd/yyyy h:mm:ss tt", cultureinfo.invariantculture);
if want convert resulting datetime
stering format: dd-mmm-yyyy hh:mm
:
string result = dt.tostring("dd-mmm-yyyy hh:mm", cultureinfo.invariantculture);
cultureinfo.invariantculture
forces english language month names instead of localized name.
c#-4.0
No comments:
Post a Comment