从后端集 bootstrap 格式正确的日期选择器加载日期数据

date data loading from backend set bootstrap datepicker in correct format

我为我的日历使用 bootstrap 日期选择器插件,我在格式化我的加载数据时遇到了一点问题,我想在我的页面加载时获得这种类型的日期格式 dd/M/yyyy = 15/Nov/2017

能帮帮我吗,非常感谢!

步骤 1) 是我的静态 HTML, 加载我的页面时的步骤 2)

Step 1)

<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/M/yyyy" value="@Model.LiveDate">

Step 2)

<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/M/yyyy" value="06.06.2017 00:00:00">

jsfiddle

尝试以所需格式设置值。 喜欢

<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/M/yyyy" value="@Model.LiveDate.ToString("dd/MMM/yyyy");">

会是这样的。在某些情况下,它看起来像第一个,在属性中它应该有 Value 方法

1)

<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/M/yyyy" value="@Model.LiveDate.Value.ToString("dd/MMM/yyyy", System.Globalization.CultureInfo.InvariantCulture)">

在某些情况下没有值属性。

2)

<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/M/yyyy" value="@Model.LiveDate.ToString("dd/MMM/yyyy", System.Globalization.CultureInfo.InvariantCulture)">