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
Post a Comment