如何设置格式HH:mm

时间:2013-01-04 09:43:40

标签: javascript jquery asp.net-mvc internet-explorer

JS:

$(".time").timeEntry({ show24Hours: true });

HTML:

<td>@Html.TextBox("TimeFrom", Model.TimeFrom.ToString(), new {@class = "time"})</td> 

我看格式HH:mm:ss,我需要HH:mm

enter image description here

这是怎么做到的?

浏览器IE9

我创建测试视图:

@model DateTime
@{
    Layout = null;
}

<link href="@Url.Content("~/Content/themes/base/jquery.timeentry.css")"  rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery/jquery-1.8.2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery/jquery.timeentry.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $(".time").timeEntry({ show24Hours: true, showSeconds: false });
    });
</script>
@Html.TextBox("TimeFrom", Model.ToString(), new { @class = "time" })

timeEntry仅在焦点

之后才会发挥作用

我使用http://keith-wood.name/timeEntry.html最后一个版本

3 个答案:

答案 0 :(得分:0)

喜欢这个吗?

$(".time").timeEntry({ show24Hours: true, showSeconds: false });

答案 1 :(得分:0)

试试这个

$(".time").timeEntry({ show24Hours: true, showSeconds: false });

根据docs ..里面的快速参考你可以看到

showSeconds: false, // True to show seconds as well, false for hours/minutes only 

答案 2 :(得分:0)

您是否尝试过设置初始文本框值的格式?

@Html.TextBox("TimeFrom", Model.ToString("HH:mm"), new { @class = "time" })

它对我有用。