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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -