ASP.Net MVC jQuery UI DatePicker 日期格式 [英] ASP.Net MVC jQuery UI DatePicker Date Format

查看:24
本文介绍了ASP.Net MVC jQuery UI DatePicker 日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何强制这个 jQuery datepicker 控件理解特定的日期格式.这到底是怎么回事?

I'm at my wits end trying to force this jQuery datepicker control to understand specific date formats. What the hell is going on here?

查看

@Html.TextBoxFor(model => model.StartDate, "{0:dd/MM/yyyy}", new { @class = "datefield" })

Javascript

$(function () {
    $(".datefield").datepicker({
        dateFormat: 'dd/MM/yyyy',
        showOn: "button"
    });
});

页面加载

点击日期选择器,到目前为止一切顺利

datepicker clicked, so far so good

选择的日期……什么?

推荐答案

根据文档:

  • dd - 月份中的第几天(两位数)
  • MM - 月份名称长
  • yy - 年份(四位数)
  • dd - day of month (two digit)
  • MM - month name long
  • yy - year (four digit)

所以 dd/MM/yyyy 应该产生那个结果.(日期、长月份名称和 4 位数年份两次.)要匹配您最初加载的格式,您需要:

So dd/MM/yyyy should produce that result. (The day, the long month name, and the 4-digit year twice.) To match your initially loaded format, you'd want this:

dd/mm/yy

这篇关于ASP.Net MVC jQuery UI DatePicker 日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆