asp.net - How convert a string into Datetime in c# -


i want convert string "12092014" datetime object 12 september 2014.

if ddmmyyyy standard date , time format of currentculture, can use datetime.parse directly;

var date = datetime.parse("12092014"); 

if not, can use custom date , time format datetime.tryparseexact method like;

string s = "12092014"; datetime dt; if(datetime.tryparseexact(s, "ddmmyyyy",                           cultureinfo.invariantculture,                           datetimestyles.none, out dt)) {     console.writeline(dt); } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -