如何在asp.net中将日期10/05/2014转换为2014年5月10日 [英] How to convert date 10/05/2014 to 10-May-2014 in asp .net
本文介绍了如何在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..
这篇关于如何在asp.net中将日期10/05/2014转换为2014年5月10日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文