如何在MVC剃须刀中设置日期格式 [英] How to set date format in MVC razor
本文介绍了如何在MVC剃须刀中设置日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在此格式中显示日期格式化
i want to display date formate in this formate
18th June 1990
当前这个
currenlty in this
18 November 1990
形成但是我要求第18次 。
我用这种格式更改了所以我可以显示日期。
< b>我尝试了什么:
formate but i requried 18th "th".
what i change in this format so i can display th in date.
What I have tried:
@Convert.ToString(string.Format("{0:d MMMM yyyy}
推荐答案
请参阅此 datetime - 怎么能我在c#中格式化日期 - Stack Overflow [ ^ ]创建一个新的自定义日期格式提供程序
自定义格式
to
refer this datetime - How can i format the date in c# - Stack Overflow[^] to create a newcustom date format provider
customize theformat
to
return string.Format(" {1}{2} {0:MMMM} {0:yyyy}", arg, dt.Day, suffix);
将您的代码更改为
change your code to
@string.Format(new MyCustomDateProvider(), "{0}", item.ValidDate);
这篇关于如何在MVC剃须刀中设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文