My system date format is dd-MM-yyyy(20-10-2012) and I'm getting the date and using separator to split the date, month and year. I need to convert date format (dd/MM/yyyy) whether the formats returns at any date format.
string sDate = string.Empty;
DateTime _date = DateTime.Now;
int count = 0;
string format = "dd-MM-yyyy";
sDate = dateFormat.ToString(format);
string[] Words = sDate.Split(new char[] { '-' });
foreach (string Word in Words)
{
count += 1;
if (count == 1) { Day = Word; }
if (count == 2) { Month = Word; }
if (count == 3) { Year = Word; }
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…