为什么日期时间选择器给出月份名称而不是数字?
我正在尝试在我的应用程序中使用 DateTimePicker。 我在 View/Shared/EditorTemplates 文件夹下创建 Date.cshtml 它包含这样的内容:
@model System.DateTime
@Html.TextBox("", Model.ToString("dd-MM-yyyy"),
new {@class = "tanggal", @maxlength = "10"})
然后我在脚本文件夹下创建 EditorHookup.js 文件,其内容如下:
$(document).ready(function () {
$('.tanggal').datepicker({
dateFormat: 'dd-MM-yyyy'
});
});
我希望得到的结果是这样的: 01-01-2012 但结果是: 01-January-20122012
我应该做什么来解决这个问题?
I'm trying to use DateTimePicker in my application.
I create Date.cshtml under the View/Shared/EditorTemplates folder
and it consist something like this:
@model System.DateTime
@Html.TextBox("", Model.ToString("dd-MM-yyyy"),
new {@class = "tanggal", @maxlength = "10"})
then I create EditorHookup.js file under the script folder with the content like this:
$(document).ready(function () {
$('.tanggal').datepicker({
dateFormat: 'dd-MM-yyyy'
});
});
I expect to get the result to be like this: 01-01-2012
but the result is: 01-January-20122012
What should I do to fix that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
mm
表示月份,而不是MM
。请参阅此处: http://docs.jquery.com/UI/Datepicker/formatDate例如:
Use
mm
for month instead ofMM
. See here: http://docs.jquery.com/UI/Datepicker/formatDateE.g.:
仔细检查日期选择器的文档,特别是有关月份的代码。我猜你想要类似
mm
而不是MM
的东西。Double-check the documentation for your datepicker, specifically regarding the code for month. I'd guess that you want something like
mm
instead ofMM
.你可以尝试
http://jqueryui.com/demos/datepicker/#option-dateFormat
can you try
http://jqueryui.com/demos/datepicker/#option-dateFormat