【问题标题】:angularjs daterangepicker calendar shows Incorrect dateangularjs daterangepicker 日历显示不正确的日期
【发布时间】:2020-05-16 19:02:20
【问题描述】:

我在我的 angularjs 应用程序中使用angularjs-daterangepicker。从下图中可以看出,日期显示错误。

   <button type="button"
       ng-click="$ctrl.DateRangeChanged()"
       date-range-picker="$ctrl.durationDateRange"
       ng-model="$ctrl.date"
       options="$ctrl.options" >Customize
   </button>

并且日期范围选项如下

this.options = {
  pickerClasses: 'custom-display', // angular-daterangepicker extra
  buttonClasses: 'btn',
  applyButtonClasses: 'btn-primary',
  cancelButtonClasses: 'btn-danger',
  locale: {
    applyLabel: 'Apply',
    cancelLabel: 'Cancel',
    customRangeLabel: 'Custom range',
    separator: ' - ',
    format: 'YYYY-MM-DD', // will give you 2017-01-06
    // format: "D-MMM-YY", // will give you 6-Jan-17
    // format: "D-MMMM-YY", //will give you 6-January-17
  },
  timePicker: true,
  autoApply: true,
  showDropdowns: true,
  startDate: (moment()).startOf('day'),
};

【问题讨论】:

    标签: angularjs bootstrap-datetimepicker


    【解决方案1】:

    您必须在输入中添加日期范围选择器选项

    <button type="button"
           ng-click="$ctrl.DateRangeChanged()"
           date-range-picker="$ctrl.durationDateRange"
           ng-model="$ctrl.date"
           date-range-picker-options="$ctrl.options" >Customize
       </button>
    

    【讨论】:

    • 如果您查看日历,5 月 1 日是错误的。选项在这里工作正常
    • startDate: (moment()) 你能像这样传递开始日期吗
    • 没有任何影响。
    猜你喜欢
    • 1970-01-01
    • 2014-12-20
    • 2015-10-01
    • 1970-01-01
    • 2022-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 2018-11-26
    相关资源
    最近更新 更多