尝试制作多语言日期选择器

时间:2018-11-07 05:00:58

标签: jquery angularjs

我有一个日期选择器,并使用uib-datepicker-popup格式更改日期选择器的语言。 html文件:

<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-isolate-scope ng-not-empty ng-valid-date ng-valid-required" show-button-bar="false" uib-datepicker-popup="{{dateFormat}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" ng-required="true" close-text="Close" alt-input-formats="altInputFormats" readonly="" required="required" ng-init="initDt()" ng-change="changeDt()">

js:

if ($scope.langCode == "jpn") {
    $scope.dateFormat = 'yyyy年m月d日';
     } else if($scope.langCode == "eng") {
    $scope.dateFormat = 'yyyy/m/d';
     }

enter image description here

问题是每次我更改日期时月份自动增加(超过12)。

1 个答案:

答案 0 :(得分:0)

问题在于m用于解析分钟,而不是您期望的月份。使用MMM来解析月份。

在此处查看Dateparser文档:https://angular-ui.github.io/bootstrap/,以查看所有格式代码所引用的内容。