【发布时间】:2012-10-20 06:13:02
【问题描述】:
获取 MM/dd/yyyy 的 CultureInfo.InvariantCulture 格式。但我想得到 dd/MM/yyyy 格式,我想分割日月年。
这是我的代码:
string sDate = string.Empty;
DateTime _date = DateTime.Now;
DateTime dateFormat = Convert.ToDateTime(_date.ToString(CultureInfo.InvariantCulture));
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; }
}
【问题讨论】: