嗨,我正在使用 angularjs datepicker 功能,使用npm i angularjs-datepicker
工作正常,但我需要显示时间,如(15-12-2017 05:14 PM)帮助如何格式化 datepicker 在这里我提到了参考链接,我也厌倦了控制器它来了但是当我点击日期选择器日期显示错误。有任何指定格式是否有帮助或如何解决该问题
https://www.npmjs.com/package/angularjs-datepicker
html
<div class="hackyhack" datepicker datepicker-class="test-custom-class"
date-format="dd-MM-y" >
<input type="text" id="AddQuoteDate" name="QuoteDate" size="4"
ng-model="QuoteDate" placeholder="Enter Quote Date"
ng-change="QuoteDatechange(QuoteDate)"
class="form-control angular-datepicker-input"
required title="Enter Quote Date"/>
</div>
控制器
$scope.QuoteDatechange = function (Quotedate) {
var date = new Date();
var hours = date.getHours() > 12 ? date.getHours() - 12 : date.getHours();
var am_pm = date.getHours() >= 12 ? "PM" : "AM";
hours = hours < 10 ? "0" + hours : hours;
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
time = hours + ":" + minutes + ":" + seconds + " " + am_pm;
$scope.QuoteDate = Quotedate + " " + time;
}