c# - Converting string to date 12/29/2014 00:00:00.000 -
i not able convert string of following format "12/29/2014 00:00:00.000" datetime value....i tried using following code.
can me please.
var value = "12/29/2014 00:00:00.000"; datetime validdate = new datetime(); datetime.tryparseexact(value, "yyyy-mm-dd hh:mm:ss.sss", null,system.globalization.datetimestyles.none,out validdate); datetime.tryparseexact(value, "mm/dd/yyyy hh:mm:ss.sss", null, system.globalization.datetimestyles.none, out validdate); datetime.tryparseexact(value, "mm/dd/yyyy", null, system.globalization.datetimestyles.none, out validdate); console.writeline(validdate);
try one
using system; public class program { public static void main() { var date = "12/29/2014 00:00:00.000"; iformatprovider culture = new system.globalization.cultureinfo("en-us", true); datetime checkindate = convert.todatetime(date, culture); console.writeline(checkindate); } }
use cultureinfo
thanks
Comments
Post a Comment