c# - Format datetime from string "20151210T11:25:11123" -


i have string format "20151210t11:25:11123", can't convert type datetime in c# me?

string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "dd/mm/yyyy hh:mm tt", cultureinfo.invariantculture); 

you using time of 20151210t11:25:11123 telling parse if formatted dd/mm/yyyy hh:mm tt. format not match string, formatexception. need provide format matches string have. isn't clear me last 5 digits format yyyymmddthh:mm:ssfff parse string 12/10/2015 11:25:11 am. may need adjust last part of format match whatever encoded there in string.

string date = "20151210t11:25:11123"; datetime datea = datetime.parseexact(date, "yyyymmddthh:mm:ssfff", cultureinfo.invariantculture) console.writeline(datea); // 12/10/2015 11:25:11 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -