DateTime.ParseExact which parses a date that exactly matches a format you supply.
OR
string date1 = "12/29/2011";
DateTime date2 = DateTime.ParseExact(date1,
"MM/dd/yyyy", null);
null means the current culture.
using System.Globalization;
date2 = DateTime.ParseExact(date1,
"MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
No comments:
Post a Comment