我试着转换这个
DateTime Todate = DateTime.ParseExact("22/08/2012", "dd/MM/yyyy", null);
得到输出:
8/21/2012 12:00:00 AM
如何在 dd/MM/yyyy 中获取日期输出
编辑: 我从日历文本框中获取文本作为字符串“22/08/2012”,现在我需要将其转换为 dateTime 数据类型以通过 DateTime DataType 中的 DAL 类变量插入到 DB
string[] f1 = datepicker1.Text.Split(' ');
string[] t1 = datepicker2.Text.Split(' ');
DateTime Fromdate1 = DateTime.ParseExact(f1[0], "dd/MM/yyyy", CultureInfo.InvariantCulture);
//Convert.ToDateTime(datepicker1.Text);
DateTime Todate1 = DateTime.ParseExact(t1[0], "dd/MM/yyyy", null);
ObjSeasonPrice.SeasonPriceName = txtSeasonPriceName.Text.Trim();
ObjSeasonPrice.PropertyId = Convert.ToInt32(propId.ToString());
ObjSeasonPrice.RoomId = Convert.ToInt32(roomId.ToString());
ObjSeasonPrice.RatePerNight = Convert.ToDecimal(txtRatePerNight.Text);
ObjSeasonPrice.Days = getAllDaysWithComma();
ObjSeasonPrice.AdditionalBenefits = txtAdditionalBenifits.Text.Trim();
ObjSeasonPrice.Status = ddlStatus.SelectedItem.ToString();
ObjSeasonPrice.IsDeleted = Convert.ToBoolean("False");
ObjSeasonPrice.FromDate = Fromdate1;
ObjSeasonPrice.ToDate = Todate1;
抱歉信息太少,但为什么你们一直在投票而没有花时间完全理解这个问题。