public DateTime GetBDFormatedDate(string _date)
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateTime = _date;
string[] formats = { "dd/MM/yyyy", "dd-MM-yyyy", "d/M/yyyy", "d.M.yyyy", "d-M-yyyy", "d M yyyy", "d/M/yy", "d.M.yy", "d-M-yy", "d M yy", "MM/dd/yyyy", "MM-dd-yyyy", "M/d/yyyy", "M.d.yyyy", "M-d-yyyy", "M-d-yyyy", "M/d/yy", "M.d.yy", "M-d-yy", "M d yy" };
DateTime dtdateTime = DateTime.Now;
try
{
dtdateTime = DateTime.ParseExact(dateTime, formats, provider, DateTimeStyles.AdjustToUniversal);
}
catch { }
return dtdateTime;
}
{
CultureInfo provider = CultureInfo.InvariantCulture;
string dateTime = _date;
string[] formats = { "dd/MM/yyyy", "dd-MM-yyyy", "d/M/yyyy", "d.M.yyyy", "d-M-yyyy", "d M yyyy", "d/M/yy", "d.M.yy", "d-M-yy", "d M yy", "MM/dd/yyyy", "MM-dd-yyyy", "M/d/yyyy", "M.d.yyyy", "M-d-yyyy", "M-d-yyyy", "M/d/yy", "M.d.yy", "M-d-yy", "M d yy" };
DateTime dtdateTime = DateTime.Now;
try
{
dtdateTime = DateTime.ParseExact(dateTime, formats, provider, DateTimeStyles.AdjustToUniversal);
}
catch { }
return dtdateTime;
}
No comments:
Post a Comment