我的系统日期格式是 dd-MM-yyyy(20-10-2012),我正在获取日期并使用分隔符来分割日期、月份和年份。无论格式是否以任何日期格式返回,我都需要转换日期格式(dd/MM/yyyy)。
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; }
}