如何在asp.net中将日期10/05/2014转换为2014年5月10日
问题描述:
如何将日期10/05/2014转换为2014年5月10日在asp .net
How to convert date 10/05/2014 to 10-May-2014 in asp .net
答
string date = Convert.ToDateTime("10 / 05 / 2014").ToString("dd-MMM-yyyy");
string formattedDate = YourDate.ToString("dd MMM yyyy");
我假设你有10/05/2014作为字符串
,而不是日期时间
。所以解决方案是
I am assuming you have 10/05/2014 asstring
, not aDateTime
. So solution would be
string time = DateTime.ParseExact("10/05/2014","dd/MM/yyyy",CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy");
如果 DateTime
而不仅仅是 ToString(dd-MMM-yyyy)
将有效。
问候..
If its DateTime
than just ToString("dd-MMM-yyyy")
will work.
Regards..