asp.net mvc - Format Date to only Month and Year - "MMM-yyyy" -
i working on mvc 4.0./c#/razor view. in model have date
[display(name = "for period")] [displayformat(dataformatstring = "{0:dd-mmm-yyyy}")] public system.datetime forperiod { get; set; }
and in view getting date using
@html.displayfor(modelitem => item.forperiod)
and in result getting date in "12-may-2015" format. want skip day date , in result want "may-2015".
my question should used in view "mmm-yyyy" format?
you can format date in view file following way
<span>@convert.todatetime(item.effectivedate).tostring("mmm-yyyy")</span>
for can format date model
[display(name = "for period")] [displayformat(dataformatstring = "{0:mmm-yyyy}")] public system.datetime forperiod { get; set; }
Comments
Post a Comment