简体   繁体   English

带有日历的100之前的ui datepicker

[英]ui datepicker before 100 with calendar

I have an input with a datepicker. 我有一个带日期选择器的输入。 It works properly, but when I insert a date before 01/01/100 it shows me 19xx. 它可以正常工作,但是当我在01/01/100之前插入日期时,它显示为19xx。

For example, if I insert 01/01/0001 the calendar shows me 01/01/1901 例如,如果我插入01/01/0001,则日历显示为01/01/1901

在此处输入图片说明

I have read that I have to use yearRange in my script, but it doesn't work for me :( 我已经读到我必须在脚本中使用yearRange,但是它对我不起作用:(

<script type="text/javascript">
    $( document ).ready(function() {
        $("#fromDatePickerEnabled_input").datepicker({
            yearRange: '1:9999'
        });
    });
</script>

How can I make that it shows me the year right? 如何使它向我显示正确的年份?

It's already reported / discussed bug in the jQuery forums , since 2016, and unfortunately there aren't any fixes yet ... 自2016年以来, 它已经在jQuery论坛中报告/讨论了错误 ,不幸的是还没有任何修复...

In short : Looks like jQuery Datepicker doesn't work correctly with dates which years are less than 1000. 简而言之 :看起来jQuery Datepicker无法正确使用年份小于1000的日期。

I tried passing different options to Datepicker (as changeYear , shortYearCutoff , yearRange ), but no one fixes the problem. 我尝试将不同的选项传递给changeYear (如changeYearshortYearCutoffyearRange ),但没有人解决此问题。 Even enabling changeYear: true and manually selecting the year, doesn't result in a correct Date. 即使启用changeYear: true并手动选择年份,也不会产生正确的Date。

It's an option to switch to bootstrap-datepicker , which doesn't have such problems with lower years. 这是切换到bootstrap-datepicker 的一种 选择 ,它在较低的年份没有这种问题。

Here you can play with it: bootstrap-datepicker playground 在这里您可以使用它: bootstrap-datepicker游乐场

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM