Javascript DatePicker格式的2位数字年份 [英] Javascript DatePicker format year in 2 digits

查看:85
本文介绍了Javascript DatePicker格式的2位数字年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用日期选择器. 我遇到的问题是,年份给了我4位数字.

I'm using datepicker. The problem I'm having is that the year is giving me 4 digits.

$.datepicker.setDefaults({
    dateFormat: 'dd-mm-yy'
});

您不应该只给我2位数字吗?

Shouldn't yy give me only 2 digits?

我如何在一年中获得两位数而不是4位?

How do I get 2 digits on the year instead of 4?

推荐答案

这是关于JQuery的. 文件: http://api.jqueryui.com/datepicker/

This is about JQuery. Docs: http://api.jqueryui.com/datepicker/

y - year (two digit)
yy - year (four digit)

所以:

$.datepicker.setDefaults({
    dateFormat: 'dd-mm-y'
});

这篇关于Javascript DatePicker格式的2位数字年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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