發(fā)表日期:2019-04 文章編輯:小燈 瀏覽次數(shù):2946
先看下面這個例子,讀取信息表的的數(shù)據(jù):
<ul> ????@foreach(var?item?in?Html.InfoDataList(new?{Table="news"})) ????{ ????????string?url?=?Html.InfoDataUrl((int)item.ColumnId,(int)item.Id); ????????<li?class="item?clearfix"> ??????????<a?href="@url"?target="_blank">@item.Title</a>?@item.Thedate.ToString("yyyy-MM-dd") ????????</li> ????} </ul>
顯示結(jié)果如下圖:
模板中日期字段調(diào)用了ToString("yyyy-MM-dd")來進行日期的格式化。
下面就列舉一些基礎(chǔ)格式的語法:
ToString("yyyy");???????? //年長格式: 2019
ToString("yy");??????? ?? //年短格式:19
ToString("MM");??????? //月份格式:03
ToString("M");??????? ?? //月份短格式:3
ToString("MMM");??? //月份格式: 三月
ToString("dd");????????? //日格式:10
ToString("HH");???????? //小時格式:14
ToString("mm");??????? //分鐘格式:45
ToString("ss");???????? ?? //秒格式:49
ToString("dddd");????? //星期格式: 星期五
ToString("ddd");????? //星期短格式: 周五
上面基礎(chǔ)格式可以自由組合,如:
ToString("yyyy-MM-dd dddd HH:mm:ss");? //格式: 2019-03-10 星期五 14:45:49
請根據(jù)自己需求自行發(fā)揮。
日期:2019-04 瀏覽次數(shù):3145
日期:2019-04 瀏覽次數(shù):3120
日期:2019-04 瀏覽次數(shù):3029
日期:2019-04 瀏覽次數(shù):2856
日期:2019-04 瀏覽次數(shù):2945
日期:2019-04 瀏覽次數(shù):3112
日期:2019-04 瀏覽次數(shù):3048
日期:2019-04 瀏覽次數(shù):3310
日期:2019-04 瀏覽次數(shù):3361
日期:2019-04 瀏覽次數(shù):3013
日期:2019-04 瀏覽次數(shù):3389
日期:2019-04 瀏覽次數(shù):2811
日期:2019-04 瀏覽次數(shù):2954
日期:2019-04 瀏覽次數(shù):3072
日期:2019-04 瀏覽次數(shù):2922
日期:2019-04 瀏覽次數(shù):3367
日期:2019-04 瀏覽次數(shù):3267
日期:2019-04 瀏覽次數(shù):2947
日期:2019-04 瀏覽次數(shù):3171
日期:2019-04 瀏覽次數(shù):3005
日期:2019-04 瀏覽次數(shù):2776
日期:2019-04 瀏覽次數(shù):3082
日期:2019-04 瀏覽次數(shù):2972
日期:2019-04 瀏覽次數(shù):3071
日期:2019-04 瀏覽次數(shù):3023
日期:2019-04 瀏覽次數(shù):2895
日期:2019-04 瀏覽次數(shù):2749
日期:2019-04 瀏覽次數(shù):2765
日期:2019-04 瀏覽次數(shù):2828
日期:2019-04 瀏覽次數(shù):2853
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.