c# - Time are being displayed wrong even formatted -


i'm trying format time. want show in hh:mm format. i'm passing dictionary view contains list of datetime objects. has format:

var mapmovies = new dictionary<string, list<datetime>>(); 

pretty simple. doing in view:

foreach(var time in movie.value) {     @html.displayfor(modelitem => time.tostring("{0:hh:mm}")) } 

when reaches point got known "templates can used field access, property access, single-dimension array index, or single-parameter custom indexer expressions." exception. removing tostring("{0:hh:mm}") displays incorrectly in format {0:dd/mm/yyyy hh:mm} me it's strange thing format time again because in model that:

[datatype(datatype.time)] [displayformat(applyformatineditmode = true, dataformatstring = "{0:hh:mm}")] public datetime sessiontime { get; set; } 

if have defined way want show in model, why happening?

adopted solution format time in controller

mapmovies[s.movie.moviename].add(s.sessiontime.tostring("hh:mm")); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -