将字符串 mm/dd/yyyy 格式日期更改为日期时间 dd/mm/yyyy 格式日期
Change string mm/dd/yyyy format date to datetime dd/mm/yyyy format date
我在控制器中使用字符串接受日期参数。
public ActionResult Export(string fromDate, string toDate)
{
if (!string.IsNullOrEmpty(fromDates))
DateTime dDate = DateTime.Parse(fromDates);
if (!string.IsNullOrEmpty(toDates))
DateTime dDate = DateTime.Parse(toDates);
}
从 "03/30/2018" to 30/03/2018 12:00:00 AM
转换
请帮助我。谢谢
将 DateTime.ParseExact
与 CultureInfo.InvariantCulture
一起使用:
DateTime fromDateDt = DateTime.ParseExact( fromDate, "MM/dd/yyyy", CultureInfo.InvariantCulture );
DateTime toDateDt = DateTime.ParseExact( toDate , "MM/dd/yyyy", CultureInfo.InvariantCulture );
使用 DateTme.ParseExact
您可以尝试使用以下代码:
DateTime ConvertedVal = DateTime.ParseExact("03/30/2018", "MM/dd/yyyy", null);
我在控制器中使用字符串接受日期参数。
public ActionResult Export(string fromDate, string toDate)
{
if (!string.IsNullOrEmpty(fromDates))
DateTime dDate = DateTime.Parse(fromDates);
if (!string.IsNullOrEmpty(toDates))
DateTime dDate = DateTime.Parse(toDates);
}
从 "03/30/2018" to 30/03/2018 12:00:00 AM
请帮助我。谢谢
将 DateTime.ParseExact
与 CultureInfo.InvariantCulture
一起使用:
DateTime fromDateDt = DateTime.ParseExact( fromDate, "MM/dd/yyyy", CultureInfo.InvariantCulture );
DateTime toDateDt = DateTime.ParseExact( toDate , "MM/dd/yyyy", CultureInfo.InvariantCulture );
使用 DateTme.ParseExact
您可以尝试使用以下代码:
DateTime ConvertedVal = DateTime.ParseExact("03/30/2018", "MM/dd/yyyy", null);